From fde3252924d2d34bf9ac75bbade09ed446d7eed2 Mon Sep 17 00:00:00 2001 From: Jens Oberender Date: Tue, 12 Mar 2019 04:57:57 +0100 Subject: [PATCH] Port of @ngaya-ll 's pull request from swagger to openapi. (#2356) See https://github.com/swagger-api/swagger-codegen/pull/8053 --- .../libraries/okhttp-gson/ApiClient.mustache | 45 +- .../okhttp-gson/ProgressRequestBody.mustache | 12 +- .../okhttp-gson/ProgressResponseBody.mustache | 12 +- .../Java/libraries/okhttp-gson/api.mustache | 52 +- .../okhttp-gson/.openapi-generator/VERSION | 2 +- .../java/okhttp-gson/README.md | 6 +- .../java/okhttp-gson/build.gradle | 15 +- .../java/okhttp-gson/build.sbt | 10 +- .../java/okhttp-gson/docs/FakeApi.md | 10 +- .../java/okhttp-gson/pom.xml | 38 +- .../org/openapitools/client/ApiClient.java | 161 +++-- .../client/GzipRequestInterceptor.java | 2 +- .../client/ProgressRequestBody.java | 16 +- .../client/ProgressResponseBody.java | 20 +- .../org/openapitools/client/api/FakeApi.java | 93 +-- .../client/auth/HttpBasicAuth.java | 2 +- .../org/openapitools/client/auth/OAuth.java | 39 -- .../openapitools/client/auth/OAuthFlow.java | 18 - .../client/auth/OAuthOkHttpClient.java | 68 -- .../client/auth/RetryingOAuth.java | 174 ----- .../client/model/ModelReturn.java | 1 - .../openapitools/client/api/FakeApiTest.java | 6 +- .../org/openapitools/client/ApiClient.java | 45 +- .../client/ProgressRequestBody.java | 12 +- .../client/ProgressResponseBody.java | 12 +- .../client/api/AnotherFakeApi.java | 46 +- .../org/openapitools/client/api/FakeApi.java | 599 +++--------------- .../client/api/FakeClassnameTags123Api.java | 46 +- .../org/openapitools/client/api/PetApi.java | 414 ++---------- .../org/openapitools/client/api/StoreApi.java | 184 +----- .../org/openapitools/client/api/UserApi.java | 368 ++--------- .../client/api/AnotherFakeApiTest.java | 8 +- .../openapitools/client/api/FakeApiTest.java | 37 +- .../api/FakeClassnameTags123ApiTest.java | 4 +- .../openapitools/client/api/PetApiTest.java | 26 +- .../openapitools/client/api/StoreApiTest.java | 4 +- .../openapitools/client/api/UserApiTest.java | 16 +- .../org/openapitools/client/ApiClient.java | 45 +- .../client/ProgressRequestBody.java | 12 +- .../client/ProgressResponseBody.java | 12 +- .../client/api/AnotherFakeApi.java | 46 +- .../org/openapitools/client/api/FakeApi.java | 599 +++--------------- .../client/api/FakeClassnameTags123Api.java | 46 +- .../org/openapitools/client/api/PetApi.java | 414 ++---------- .../org/openapitools/client/api/StoreApi.java | 184 +----- .../org/openapitools/client/api/UserApi.java | 368 ++--------- .../client/api/AnotherFakeApiTest.java | 4 +- .../openapitools/client/api/FakeApiTest.java | 37 +- .../api/FakeClassnameTags123ApiTest.java | 4 +- .../openapitools/client/api/StoreApiTest.java | 4 +- .../openapitools/client/api/UserApiTest.java | 16 +- .../client/model/XmlItemTest.java | 36 +- 52 files changed, 984 insertions(+), 3466 deletions(-) delete mode 100644 samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuth.java delete mode 100644 samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthFlow.java delete mode 100644 samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java delete mode 100644 samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/RetryingOAuth.java 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 c998ecde892..bdae7a66aa7 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 @@ -136,7 +136,9 @@ public class ApiClient { {{/oauthMethods}} {{/hasOAuthMethods}} private void init() { - httpClient = new OkHttpClient(); + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addInterceptor(getProgressInterceptor()); + httpClient = builder.build(); {{#useGzipFeature}} // Enable gzip request compression @@ -189,7 +191,7 @@ public class ApiClient { * @return Api Client */ public ApiClient setHttpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; + this.httpClient = httpClient.newBuilder().addInterceptor(getProgressInterceptor()).build(); return this; } @@ -1066,12 +1068,12 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP call * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener); + public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, callback); return httpClient.newCall(request); } @@ -1087,11 +1089,11 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP request * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); final String url = buildUrl(path, queryParams, collectionQueryParams); @@ -1123,10 +1125,14 @@ public class ApiClient { reqBody = serialize(body, contentType); } + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + Request request = null; - if (progressRequestListener != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener); + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); request = reqBuilder.method(method, progressRequestBody).build(); } else { request = reqBuilder.method(method, reqBody).build(); @@ -1270,6 +1276,27 @@ public class ApiClient { } } + /** + * 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. diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressRequestBody.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressRequestBody.mustache index d9ceeab12ab..71e1e2b4cbe 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressRequestBody.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressRequestBody.mustache @@ -15,17 +15,13 @@ import okio.Sink; public class ProgressRequestBody extends RequestBody { - public interface ProgressRequestListener { - void onRequestProgress(long bytesWritten, long contentLength, boolean done); - } - private final RequestBody requestBody; - private final ProgressRequestListener progressListener; + private final ApiCallback callback; - public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) { + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { this.requestBody = requestBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -59,7 +55,7 @@ public class ProgressRequestBody extends RequestBody { } bytesWritten += byteCount; - progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength); + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); } }; } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressResponseBody.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressResponseBody.mustache index 34713eca118..50f2eba395a 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressResponseBody.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ProgressResponseBody.mustache @@ -15,17 +15,13 @@ import okio.Source; public class ProgressResponseBody extends ResponseBody { - public interface ProgressListener { - void update(long bytesRead, long contentLength, boolean done); - } - private final ResponseBody responseBody; - private final ProgressListener progressListener; + private final ApiCallback callback; private BufferedSource bufferedSource; - public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) { + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { this.responseBody = responseBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -55,7 +51,7 @@ public class ProgressResponseBody extends ResponseBody { 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; - progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); return bytesRead; } }; 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 a06c2e35d59..cf90c4ee1db 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 @@ -66,8 +66,7 @@ public class {{classname}} { {{^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 _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object {{#isDeprecated}} @@ -81,7 +80,7 @@ public class {{classname}} { {{#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 ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + 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}}new Object(){{/bodyParam}}; // create path and map variables @@ -124,27 +123,15 @@ public class {{classname}} { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; - return localVarApiClient.buildCall(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } {{#isDeprecated}} @Deprecated {{/isDeprecated}} @SuppressWarnings("rawtypes") - private okhttp3.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException { {{^performBeanValidation}} {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set @@ -153,7 +140,7 @@ public class {{classname}} { } {{/required}}{{/allParams}} - okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback); return localVarCall; {{/performBeanValidation}} @@ -168,7 +155,7 @@ public class {{classname}} { parameterValues); if (violations.size() == 0) { - okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback); return localVarCall; } else { @@ -227,7 +214,7 @@ public class {{classname}} { @Deprecated {{/isDeprecated}} public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { - okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null, null); + 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}} } @@ -252,26 +239,7 @@ public class {{classname}} { {{/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}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}_progressListener, _progressRequestListener); + 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; @@ -317,8 +285,8 @@ public class {{classname}} { {{#isDeprecated}} @Deprecated {{/isDeprecated}} - public okhttp3.Call buildCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { - return {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_progressListener, _progressRequestListener); + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback); } /** diff --git a/samples/client/petstore-security-test/java/okhttp-gson/.openapi-generator/VERSION b/samples/client/petstore-security-test/java/okhttp-gson/.openapi-generator/VERSION index d077ffb477a..afa63656064 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/java/okhttp-gson/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.4-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/java/okhttp-gson/README.md b/samples/client/petstore-security-test/java/okhttp-gson/README.md index 207f36ed838..b4a27c3b7a0 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/README.md +++ b/samples/client/petstore-security-test/java/okhttp-gson/README.md @@ -84,9 +84,9 @@ public class FakeApiExample { public static void main(String[] args) { FakeApi apiInstance = new FakeApi(); - Object UNKNOWN_BASE_TYPE = new UNKNOWN_BASE_TYPE(); // Object | + String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR = "testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR_example"; // String | To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r try { - apiInstance.testCodeInjectEndRnNR(UNKNOWN_BASE_TYPE); + apiInstance.testCodeInjectEndRnNR(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR); } catch (ApiException e) { System.err.println("Exception when calling FakeApi#testCodeInjectEndRnNR"); e.printStackTrace(); @@ -98,7 +98,7 @@ public class FakeApiExample { ## Documentation for API Endpoints -All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* +All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- diff --git a/samples/client/petstore-security-test/java/okhttp-gson/build.gradle b/samples/client/petstore-security-test/java/okhttp-gson/build.gradle index 9d4f85b4459..56159bd543a 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/build.gradle +++ b/samples/client/petstore-security-test/java/okhttp-gson/build.gradle @@ -1,11 +1,13 @@ apply plugin: 'idea' apply plugin: 'eclipse' +apply plugin: 'java' group = 'org.openapitools' version = '1.0.0' buildscript { repositories { + mavenCentral() jcenter() } dependencies { @@ -17,7 +19,9 @@ buildscript { repositories { jcenter() } - +sourceSets { + main.java.srcDirs = ['src/main/java'] +} if(hasProperty('target') && target == 'android') { @@ -94,12 +98,13 @@ if(hasProperty('target') && target == 'android') { } dependencies { - compile 'io.swagger:swagger-annotations:1.5.17' - compile 'com.squareup.okhttp:okhttp:2.7.5' - compile 'com.squareup.okhttp:logging-interceptor:2.7.5' - compile 'com.google.code.gson:gson:2.8.1' + compile 'io.swagger:swagger-annotations:1.5.21' + compile 'com.squareup.okhttp3:okhttp:3.12.1' + compile 'com.squareup.okhttp3:logging-interceptor:3.12.1' + compile 'com.google.code.gson:gson:2.8.5' compile 'io.gsonfire:gson-fire:1.8.0' compile group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.1' + compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' compile 'org.threeten:threetenbp:1.3.5' testCompile 'junit:junit:4.12' } diff --git a/samples/client/petstore-security-test/java/okhttp-gson/build.sbt b/samples/client/petstore-security-test/java/okhttp-gson/build.sbt index d7dc9adb619..7f2d5f98b2b 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/build.sbt +++ b/samples/client/petstore-security-test/java/okhttp-gson/build.sbt @@ -9,10 +9,12 @@ lazy val root = (project in file(".")). publishArtifact in (Compile, packageDoc) := false, resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( - "io.swagger" % "swagger-annotations" % "1.5.17", - "com.squareup.okhttp" % "okhttp" % "2.7.5", - "com.squareup.okhttp" % "logging-interceptor" % "2.7.5", - "com.google.code.gson" % "gson" % "2.8.1", + "io.swagger" % "swagger-annotations" % "1.5.21", + "com.squareup.okhttp3" % "okhttp" % "3.12.1", + "com.squareup.okhttp3" % "logging-interceptor" % "3.12.1", + "com.google.code.gson" % "gson" % "2.8.5", + "org.apache.commons" % "commons-lang3" % "3.8.1", + "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1", "org.threeten" % "threetenbp" % "1.3.5" % "compile", "io.gsonfire" % "gson-fire" % "1.8.0" % "compile", "junit" % "junit" % "4.12" % "test", diff --git a/samples/client/petstore-security-test/java/okhttp-gson/docs/FakeApi.md b/samples/client/petstore-security-test/java/okhttp-gson/docs/FakeApi.md index a125de0a897..7a532020704 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/docs/FakeApi.md +++ b/samples/client/petstore-security-test/java/okhttp-gson/docs/FakeApi.md @@ -9,7 +9,7 @@ Method | HTTP request | Description # **testCodeInjectEndRnNR** -> testCodeInjectEndRnNR(UNKNOWN_BASE_TYPE) +> testCodeInjectEndRnNR(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR) To test code injection *_/ ' \" =end -- \\r\\n \\n \\r @@ -23,9 +23,9 @@ To test code injection *_/ ' \" =end -- \\r\\n \\n \\r FakeApi apiInstance = new FakeApi(); -UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE = new UNKNOWN_BASE_TYPE(); // UNKNOWN_BASE_TYPE | +String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR = "testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR_example"; // String | To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r try { - apiInstance.testCodeInjectEndRnNR(UNKNOWN_BASE_TYPE); + apiInstance.testCodeInjectEndRnNR(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR); } catch (ApiException e) { System.err.println("Exception when calling FakeApi#testCodeInjectEndRnNR"); e.printStackTrace(); @@ -36,7 +36,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **UNKNOWN_BASE_TYPE** | [**UNKNOWN_BASE_TYPE**](UNKNOWN_BASE_TYPE.md)| | [optional] + **testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR** | **String**| To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r | [optional] ### Return type @@ -48,6 +48,6 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json, *_/ ' =end -- + - **Content-Type**: application/x-www-form-urlencoded, *_/ ' =end -- - **Accept**: Not defined diff --git a/samples/client/petstore-security-test/java/okhttp-gson/pom.xml b/samples/client/petstore-security-test/java/okhttp-gson/pom.xml index 5fd04f361b2..125f46d977f 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/pom.xml +++ b/samples/client/petstore-security-test/java/okhttp-gson/pom.xml @@ -24,9 +24,9 @@ - OpenAPI + OpenAPI-Generator Contributors team@openapitools.org - OpenAPI + OpenAPITools.org http://openapitools.org @@ -114,8 +114,7 @@ - - src/main/java + src/main/java @@ -127,8 +126,7 @@ - - src/test/java + src/test/java @@ -194,12 +192,12 @@ ${swagger-core-version} - com.squareup.okhttp + com.squareup.okhttp3 okhttp ${okhttp-version} - com.squareup.okhttp + com.squareup.okhttp3 logging-interceptor ${okhttp-version} @@ -218,11 +216,16 @@ org.apache.oltu.oauth2.client 1.0.1 - - org.threeten - threetenbp - ${threetenbp-version} - + + org.apache.commons + commons-lang3 + ${commons-lang3-version} + + + org.threeten + threetenbp + ${threetenbp-version} + junit @@ -236,10 +239,11 @@ ${java.version} ${java.version} 1.8.0 - 1.5.18 - 2.7.5 - 2.8.1 - 1.3.5 + 1.5.21 + 3.12.1 + 2.8.5 + 3.8.1 + 1.3.5 1.0.0 4.12 UTF-8 diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java index 6cb152b0f03..0aea7e038e8 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java @@ -13,16 +13,15 @@ package org.openapitools.client; -import com.squareup.okhttp.*; -import com.squareup.okhttp.internal.http.HttpMethod; -import com.squareup.okhttp.logging.HttpLoggingInterceptor; -import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level; +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; import okio.BufferedSink; import okio.Okio; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.format.DateTimeFormatter; - import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; import org.apache.oltu.oauth2.common.message.types.GrantType; @@ -90,7 +89,7 @@ public class ApiClient { // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } - + /* * Constructor for ApiClient to support access token retry on 401/403 configured with client ID */ @@ -121,9 +120,11 @@ public class ApiClient { // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } - + private void init() { - httpClient = new OkHttpClient(); + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addInterceptor(getProgressInterceptor()); + httpClient = builder.build(); verifyingSsl = true; @@ -172,7 +173,7 @@ public class ApiClient { * @return Api Client */ public ApiClient setHttpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; + this.httpClient = httpClient.newBuilder().addInterceptor(getProgressInterceptor()).build(); return this; } @@ -424,7 +425,7 @@ public class ApiClient { if (debugging) { loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(Level.BODY); - httpClient.interceptors().add(loggingInterceptor); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); } else { httpClient.interceptors().remove(loggingInterceptor); loggingInterceptor = null; @@ -463,7 +464,7 @@ public class ApiClient { * @return Timeout in milliseconds */ public int getConnectTimeout() { - return httpClient.getConnectTimeout(); + return httpClient.connectTimeoutMillis(); } /** @@ -475,7 +476,7 @@ public class ApiClient { * @return Api client */ public ApiClient setConnectTimeout(int connectionTimeout) { - httpClient.setConnectTimeout(connectionTimeout, TimeUnit.MILLISECONDS); + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); return this; } @@ -485,7 +486,7 @@ public class ApiClient { * @return Timeout in milliseconds */ public int getReadTimeout() { - return httpClient.getReadTimeout(); + return httpClient.readTimeoutMillis(); } /** @@ -497,7 +498,7 @@ public class ApiClient { * @return Api client */ public ApiClient setReadTimeout(int readTimeout) { - httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS); + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); return this; } @@ -507,7 +508,7 @@ public class ApiClient { * @return Timeout in milliseconds */ public int getWriteTimeout() { - return httpClient.getWriteTimeout(); + return httpClient.writeTimeoutMillis(); } /** @@ -519,12 +520,13 @@ public class ApiClient { * @return Api client */ public ApiClient setWriteTimeout(int writeTimeout) { - httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS); + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); return this; } /** * 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() { @@ -635,6 +637,40 @@ public class ApiClient { return params; } + /** + * 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 @@ -658,8 +694,8 @@ public class ApiClient { * @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("*/*")); + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); } /** @@ -832,8 +868,8 @@ public class ApiClient { * Prepare file for download * * @param response An instance of the Response object - * @throws IOException If fail to prepare file for download * @return Prepared file for the download + * @throws IOException If fail to prepare file for download */ public File prepareDownloadFile(Response response) throws IOException { String filename = null; @@ -876,8 +912,8 @@ public class ApiClient { * * @param Type * @param call An instance of the Call object - * @throws ApiException If fail to execute the call * @return ApiResponse<T> + * @throws ApiException If fail to execute the call */ public ApiResponse execute(Call call) throws ApiException { return execute(call, null); @@ -918,22 +954,22 @@ public class ApiClient { /** * Execute HTTP call asynchronously. * - * @see #execute(Call, Type) * @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(Request request, IOException e) { + public void onFailure(Call call, IOException e) { callback.onFailure(new ApiException(e), 0, null); } @Override - public void onResponse(Response response) throws IOException { + public void onResponse(Call call, Response response) throws IOException { T result; try { result = (T) handleResponse(response, returnType); @@ -952,9 +988,9 @@ public class ApiClient { * @param Type * @param response Response * @param returnType Return type - * @throws ApiException If the response has an unsuccessful status code or - * fail to deserialize the response body * @return Type + * @throws 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()) { @@ -964,7 +1000,7 @@ public class ApiClient { if (response.body() != null) { try { response.body().close(); - } catch (IOException e) { + } catch (Exception e) { throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); } } @@ -996,12 +1032,12 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP call * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener); + public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, callback); return httpClient.newCall(request); } @@ -1017,11 +1053,11 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP request * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); final String url = buildUrl(path, queryParams, collectionQueryParams); @@ -1053,10 +1089,14 @@ public class ApiClient { reqBody = serialize(body, contentType); } + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + Request request = null; - if(progressRequestListener != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener); + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); request = reqBuilder.method(method, progressRequestBody).build(); } else { request = reqBuilder.method(method, reqBody).build(); @@ -1155,7 +1195,7 @@ public class ApiClient { * @return RequestBody */ public RequestBody buildRequestBodyFormEncoding(Map formParams) { - FormEncodingBuilder formBuilder = new FormEncodingBuilder(); + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); for (Entry param : formParams.entrySet()) { formBuilder.add(param.getKey(), parameterToString(param.getValue())); } @@ -1170,7 +1210,7 @@ public class ApiClient { * @return RequestBody */ public RequestBody buildRequestBodyMultipart(Map formParams) { - MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM); + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); for (Entry param : formParams.entrySet()) { if (param.getValue() instanceof File) { File file = (File) param.getValue(); @@ -1200,6 +1240,27 @@ public class ApiClient { } } + /** + * 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. @@ -1209,16 +1270,23 @@ public class ApiClient { TrustManager[] trustManagers = null; HostnameVerifier hostnameVerifier = null; if (!verifyingSsl) { - TrustManager trustAll = new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {} - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {} - @Override - public X509Certificate[] getAcceptedIssuers() { return null; } + 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[]{}; + } + } }; SSLContext sslContext = SSLContext.getInstance("TLS"); - trustManagers = new TrustManager[] {trustAll}; hostnameVerifier = new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { @@ -1246,11 +1314,12 @@ public class ApiClient { if (keyManagers != null || trustManagers != null) { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(keyManagers, trustManagers, new SecureRandom()); - httpClient.setSslSocketFactory(sslContext.getSocketFactory()); + httpClient = httpClient.newBuilder().sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]).build(); } else { - httpClient.setSslSocketFactory(null); + httpClient = httpClient.newBuilder().sslSocketFactory(null, (X509TrustManager) trustManagers[0]).build(); } - httpClient.setHostnameVerifier(hostnameVerifier); + + httpClient = httpClient.newBuilder().hostnameVerifier(hostnameVerifier).build(); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/GzipRequestInterceptor.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/GzipRequestInterceptor.java index e96eea39113..49ae0e5769e 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/GzipRequestInterceptor.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/GzipRequestInterceptor.java @@ -13,7 +13,7 @@ package org.openapitools.client; -import com.squareup.okhttp.*; +import okhttp3.*; import okio.Buffer; import okio.BufferedSink; import okio.GzipSink; diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java index 9a477ab672f..e02a8eb3df3 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java @@ -13,8 +13,8 @@ package org.openapitools.client; -import com.squareup.okhttp.MediaType; -import com.squareup.okhttp.RequestBody; +import okhttp3.MediaType; +import okhttp3.RequestBody; import java.io.IOException; @@ -26,17 +26,13 @@ import okio.Sink; public class ProgressRequestBody extends RequestBody { - public interface ProgressRequestListener { - void onRequestProgress(long bytesWritten, long contentLength, boolean done); - } - private final RequestBody requestBody; - private final ProgressRequestListener progressListener; + private final ApiCallback callback; - public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) { + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { this.requestBody = requestBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -70,7 +66,7 @@ public class ProgressRequestBody extends RequestBody { } bytesWritten += byteCount; - progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength); + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); } }; } diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java index c5995fbfab8..90108445531 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java @@ -13,8 +13,8 @@ package org.openapitools.client; -import com.squareup.okhttp.MediaType; -import com.squareup.okhttp.ResponseBody; +import okhttp3.MediaType; +import okhttp3.ResponseBody; import java.io.IOException; @@ -26,17 +26,13 @@ import okio.Source; public class ProgressResponseBody extends ResponseBody { - public interface ProgressListener { - void update(long bytesRead, long contentLength, boolean done); - } - private final ResponseBody responseBody; - private final ProgressListener progressListener; + private final ApiCallback callback; private BufferedSource bufferedSource; - public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) { + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { this.responseBody = responseBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -45,12 +41,12 @@ public class ProgressResponseBody extends ResponseBody { } @Override - public long contentLength() throws IOException { + public long contentLength() { return responseBody.contentLength(); } @Override - public BufferedSource source() throws IOException { + public BufferedSource source() { if (bufferedSource == null) { bufferedSource = Okio.buffer(source(responseBody.source())); } @@ -66,7 +62,7 @@ public class ProgressResponseBody extends ResponseBody { 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; - progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); return bytesRead; } }; diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java index be842a24fc1..1af8b736f71 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java @@ -27,7 +27,6 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; -import org.openapitools.client.model.UNKNOWN_BASE_TYPE; import java.lang.reflect.Type; import java.util.ArrayList; @@ -36,34 +35,33 @@ import java.util.List; import java.util.Map; public class FakeApi { - private ApiClient apiClient; + private ApiClient localVarApiClient; public FakeApi() { this(Configuration.getDefaultApiClient()); } public FakeApi(ApiClient apiClient) { - this.apiClient = apiClient; + this.localVarApiClient = apiClient; } public ApiClient getApiClient() { - return apiClient; + return localVarApiClient; } public void setApiClient(ApiClient apiClient) { - this.apiClient = apiClient; + this.localVarApiClient = apiClient; } /** * Build call for testCodeInjectEndRnNR - * @param UNKNOWN_BASE_TYPE (optional) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener + * @param testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public com.squareup.okhttp.Call testCodeInjectEndRnNRCall(UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = UNKNOWN_BASE_TYPE; + public okhttp3.Call testCodeInjectEndRnNRCall(String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = new Object(); // create path and map variables String localVarPath = "/fake"; @@ -72,98 +70,71 @@ public class FakeApi { List localVarCollectionQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); + if (testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR != null) { + localVarFormParams.put("test code inject */ ' " =end -- \r\n \n \r", testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR); + } + final String[] localVarAccepts = { }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); } final String[] localVarContentTypes = { - "application/json", "*_/ ' =end -- " + "application/x-www-form-urlencoded", "*_/ ' =end -- " }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - String[] localVarAuthNames = new String[] { }; - return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call testCodeInjectEndRnNRValidateBeforeCall(UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private okhttp3.Call testCodeInjectEndRnNRValidateBeforeCall(String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR, final ApiCallback _callback) throws ApiException { - com.squareup.okhttp.Call call = testCodeInjectEndRnNRCall(UNKNOWN_BASE_TYPE, progressListener, progressRequestListener); - return call; + okhttp3.Call localVarCall = testCodeInjectEndRnNRCall(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR, _callback); + return localVarCall; } /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * @param UNKNOWN_BASE_TYPE (optional) + * @param testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public void testCodeInjectEndRnNR(UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE) throws ApiException { - testCodeInjectEndRnNRWithHttpInfo(UNKNOWN_BASE_TYPE); + public void testCodeInjectEndRnNR(String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR) throws ApiException { + testCodeInjectEndRnNRWithHttpInfo(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR); } /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * @param UNKNOWN_BASE_TYPE (optional) + * @param testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse testCodeInjectEndRnNRWithHttpInfo(UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE) throws ApiException { - com.squareup.okhttp.Call call = testCodeInjectEndRnNRValidateBeforeCall(UNKNOWN_BASE_TYPE, null, null); - return apiClient.execute(call); + public ApiResponse testCodeInjectEndRnNRWithHttpInfo(String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR) throws ApiException { + okhttp3.Call localVarCall = testCodeInjectEndRnNRValidateBeforeCall(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR, null); + return localVarApiClient.execute(localVarCall); } /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (asynchronously) * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * @param UNKNOWN_BASE_TYPE (optional) - * @param callback The callback to be executed when the API call finishes + * @param testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) + * @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 */ - public com.squareup.okhttp.Call testCodeInjectEndRnNRAsync(UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE, final ApiCallback callback) throws ApiException { + public okhttp3.Call testCodeInjectEndRnNRAsync(String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = testCodeInjectEndRnNRValidateBeforeCall(UNKNOWN_BASE_TYPE, progressListener, progressRequestListener); - apiClient.executeAsync(call, callback); - return call; + okhttp3.Call localVarCall = testCodeInjectEndRnNRValidateBeforeCall(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; } } diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java index 577c1179063..184c764577d 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java @@ -15,7 +15,7 @@ package org.openapitools.client.auth; import org.openapitools.client.Pair; -import com.squareup.okhttp.Credentials; +import okhttp3.Credentials; import java.util.Map; import java.util.List; diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuth.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuth.java deleted file mode 100644 index 93a13a6d192..00000000000 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuth.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- - * - * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package org.openapitools.client.auth; - -import org.openapitools.client.Pair; - -import java.util.Map; -import java.util.List; - - -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) { - if (accessToken != null) { - headerParams.put("Authorization", "Bearer " + accessToken); - } - } -} diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthFlow.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthFlow.java deleted file mode 100644 index 9ab34d99d70..00000000000 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthFlow.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- - * - * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package org.openapitools.client.auth; - -public enum OAuthFlow { - accessCode, implicit, password, application -} diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java deleted file mode 100644 index 76b4f76af76..00000000000 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.openapitools.client.auth; - -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.MediaType; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.RequestBody; -import com.squareup.okhttp.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(mediaType, request.getBody()) : 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 - } -} diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/RetryingOAuth.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/RetryingOAuth.java deleted file mode 100644 index fb57323d09e..00000000000 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/auth/RetryingOAuth.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.openapitools.client.auth; - -import org.openapitools.client.Pair; - -import com.squareup.okhttp.Interceptor; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.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.util.Map; -import java.util.List; - -public class RetryingOAuth extends OAuth implements Interceptor { - private OAuthClient oAuthClient; - - private TokenRequestBuilder tokenRequestBuilder; - - public RetryingOAuth(OkHttpClient client, TokenRequestBuilder tokenRequestBuilder) { - this.oAuthClient = new OAuthClient(new OAuthOkHttpClient(client)); - this.tokenRequestBuilder = tokenRequestBuilder; - } - - public RetryingOAuth(TokenRequestBuilder tokenRequestBuilder) { - this(new OkHttpClient(), tokenRequestBuilder); - } - - 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)); - } - } - } - - public void setFlow(OAuthFlow flow) { - switch(flow) { - case accessCode: - 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.urlString()). - 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 - */ - 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()); - return !getAccessToken().equals(requestAccessToken); - } - } catch (OAuthSystemException | OAuthProblemException e) { - throw new IOException(e); - } - } - - return false; - } - - public TokenRequestBuilder getTokenRequestBuilder() { - return tokenRequestBuilder; - } - - 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) { - // No implementation necessary - } -} diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelReturn.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelReturn.java index 6d5ddd7c0b0..435e89bcd3f 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelReturn.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/org/openapitools/client/model/ModelReturn.java @@ -75,7 +75,6 @@ public class ModelReturn { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModelReturn {\n"); - sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore-security-test/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java index ec85133200e..ec920abcb37 100644 --- a/samples/client/petstore-security-test/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java +++ b/samples/client/petstore-security-test/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -34,15 +34,15 @@ public class FakeApiTest { /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * * @throws ApiException * if the Api call fails */ @Test public void testCodeInjectEndRnNRTest() throws ApiException { - Object UNKNOWN_BASE_TYPE = null; - api.testCodeInjectEndRnNR(UNKNOWN_BASE_TYPE); + String testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR = null; + api.testCodeInjectEndRnNR(testCodeInjectStarSlashQuoteDoubleQuoteEqualEndBackSlashRBackSlashNBackSlashNBackSlashR); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java index a9fe469fe71..c8916e7cf35 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java @@ -124,7 +124,9 @@ public class ApiClient { } private void init() { - httpClient = new OkHttpClient(); + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addInterceptor(getProgressInterceptor()); + httpClient = builder.build(); verifyingSsl = true; @@ -173,7 +175,7 @@ public class ApiClient { * @return Api Client */ public ApiClient setHttpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; + this.httpClient = httpClient.newBuilder().addInterceptor(getProgressInterceptor()).build(); return this; } @@ -1032,12 +1034,12 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP call * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener); + public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, callback); return httpClient.newCall(request); } @@ -1053,11 +1055,11 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP request * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); final String url = buildUrl(path, queryParams, collectionQueryParams); @@ -1089,10 +1091,14 @@ public class ApiClient { reqBody = serialize(body, contentType); } + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + Request request = null; - if (progressRequestListener != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener); + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); request = reqBuilder.method(method, progressRequestBody).build(); } else { request = reqBuilder.method(method, reqBody).build(); @@ -1236,6 +1242,27 @@ public class ApiClient { } } + /** + * 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. diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressRequestBody.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressRequestBody.java index f33edde76b8..1e3e1aff6ae 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressRequestBody.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressRequestBody.java @@ -26,17 +26,13 @@ import okio.Sink; public class ProgressRequestBody extends RequestBody { - public interface ProgressRequestListener { - void onRequestProgress(long bytesWritten, long contentLength, boolean done); - } - private final RequestBody requestBody; - private final ProgressRequestListener progressListener; + private final ApiCallback callback; - public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) { + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { this.requestBody = requestBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -70,7 +66,7 @@ public class ProgressRequestBody extends RequestBody { } bytesWritten += byteCount; - progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength); + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); } }; } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressResponseBody.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressResponseBody.java index 258e48eceb4..f9ddfbd35ac 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressResponseBody.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ProgressResponseBody.java @@ -26,17 +26,13 @@ import okio.Source; public class ProgressResponseBody extends ResponseBody { - public interface ProgressListener { - void update(long bytesRead, long contentLength, boolean done); - } - private final ResponseBody responseBody; - private final ProgressListener progressListener; + private final ApiCallback callback; private BufferedSource bufferedSource; - public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) { + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { this.responseBody = responseBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -66,7 +62,7 @@ public class ProgressResponseBody extends ResponseBody { 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; - progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); return bytesRead; } }; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 49f4e834540..c5392ad57ba 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -57,12 +57,11 @@ public class AnotherFakeApi { /** * Build call for call123testSpecialTags * @param body client model (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call call123testSpecialTagsCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -86,24 +85,12 @@ public class AnotherFakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call call123testSpecialTagsValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call call123testSpecialTagsValidateBeforeCall(Client body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -111,7 +98,7 @@ public class AnotherFakeApi { } - okhttp3.Call localVarCall = call123testSpecialTagsCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = call123testSpecialTagsCall(body, _callback); return localVarCall; } @@ -136,7 +123,7 @@ public class AnotherFakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse call123testSpecialTagsWithHttpInfo(Client body) throws ApiException { - okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -151,26 +138,7 @@ public class AnotherFakeApi { */ public okhttp3.Call call123testSpecialTagsAsync(Client body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java index d1fcd2043e4..a1a5d500323 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java @@ -65,12 +65,11 @@ public class FakeApi { /** * Build call for createXmlItem * @param xmlItem XmlItem Body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callback) throws ApiException { Object localVarPostBody = xmlItem; // create path and map variables @@ -94,24 +93,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createXmlItemValidateBeforeCall(XmlItem xmlItem, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createXmlItemValidateBeforeCall(XmlItem xmlItem, final ApiCallback _callback) throws ApiException { // verify the required parameter 'xmlItem' is set if (xmlItem == null) { @@ -119,7 +106,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = createXmlItemCall(xmlItem, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createXmlItemCall(xmlItem, _callback); return localVarCall; } @@ -142,7 +129,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createXmlItemWithHttpInfo(XmlItem xmlItem) throws ApiException { - okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, null, null); + okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, null); return localVarApiClient.execute(localVarCall); } @@ -156,38 +143,18 @@ public class FakeApi { */ public okhttp3.Call createXmlItemAsync(XmlItem xmlItem, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for fakeOuterBooleanSerialize * @param body Input boolean as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -211,27 +178,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterBooleanSerializeValidateBeforeCall(Boolean body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterBooleanSerializeValidateBeforeCall(Boolean body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterBooleanSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterBooleanSerializeCall(body, _callback); return localVarCall; } @@ -256,7 +211,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -271,26 +226,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterBooleanSerializeAsync(Boolean body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -298,12 +234,11 @@ public class FakeApi { /** * Build call for fakeOuterCompositeSerialize * @param body Input composite as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -327,27 +262,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterCompositeSerializeValidateBeforeCall(OuterComposite body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterCompositeSerializeValidateBeforeCall(OuterComposite body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterCompositeSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterCompositeSerializeCall(body, _callback); return localVarCall; } @@ -372,7 +295,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -387,26 +310,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterCompositeSerializeAsync(OuterComposite body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -414,12 +318,11 @@ public class FakeApi { /** * Build call for fakeOuterNumberSerialize * @param body Input number as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -443,27 +346,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterNumberSerializeValidateBeforeCall(BigDecimal body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterNumberSerializeValidateBeforeCall(BigDecimal body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterNumberSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterNumberSerializeCall(body, _callback); return localVarCall; } @@ -488,7 +379,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -503,26 +394,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterNumberSerializeAsync(BigDecimal body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -530,12 +402,11 @@ public class FakeApi { /** * Build call for fakeOuterStringSerialize * @param body Input string as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterStringSerializeCall(String body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -559,27 +430,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterStringSerializeValidateBeforeCall(String body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterStringSerializeValidateBeforeCall(String body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterStringSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterStringSerializeCall(body, _callback); return localVarCall; } @@ -604,7 +463,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterStringSerializeWithHttpInfo(String body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -619,26 +478,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterStringSerializeAsync(String body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -646,12 +486,11 @@ public class FakeApi { /** * Build call for testBodyWithFileSchema * @param body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -675,24 +514,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testBodyWithFileSchemaValidateBeforeCall(FileSchemaTestClass body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testBodyWithFileSchemaValidateBeforeCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -700,7 +527,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testBodyWithFileSchemaCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithFileSchemaCall(body, _callback); return localVarCall; } @@ -723,7 +550,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass body) throws ApiException { - okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -737,26 +564,7 @@ public class FakeApi { */ public okhttp3.Call testBodyWithFileSchemaAsync(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -764,12 +572,11 @@ public class FakeApi { * Build call for testBodyWithQueryParams * @param query (required) * @param body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -797,24 +604,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testBodyWithQueryParamsValidateBeforeCall(String query, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testBodyWithQueryParamsValidateBeforeCall(String query, User body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'query' is set if (query == null) { @@ -827,7 +622,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testBodyWithQueryParamsCall(query, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithQueryParamsCall(query, body, _callback); return localVarCall; } @@ -852,7 +647,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testBodyWithQueryParamsWithHttpInfo(String query, User body) throws ApiException { - okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, null, null); + okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, null); return localVarApiClient.execute(localVarCall); } @@ -867,38 +662,18 @@ public class FakeApi { */ public okhttp3.Call testBodyWithQueryParamsAsync(String query, User body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for testClientModel * @param body client model (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testClientModelCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -922,24 +697,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testClientModelValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testClientModelValidateBeforeCall(Client body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -947,7 +710,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testClientModelCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClientModelCall(body, _callback); return localVarCall; } @@ -972,7 +735,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testClientModelWithHttpInfo(Client body) throws ApiException { - okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -987,26 +750,7 @@ public class FakeApi { */ public okhttp3.Call testClientModelAsync(Client body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -1027,12 +771,11 @@ public class FakeApi { * @param dateTime None (optional) * @param password None (optional) * @param paramCallback None (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - 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 ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + 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 { Object localVarPostBody = new Object(); // create path and map variables @@ -1112,24 +855,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "http_basic_test" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testEndpointParametersValidateBeforeCall(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 ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testEndpointParametersValidateBeforeCall(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 { // verify the required parameter 'number' is set if (number == null) { @@ -1152,7 +883,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testEndpointParametersCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEndpointParametersCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _callback); return localVarCall; } @@ -1201,7 +932,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testEndpointParametersWithHttpInfo(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) throws ApiException { - okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null, null); + okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null); return localVarApiClient.execute(localVarCall); } @@ -1228,26 +959,7 @@ public class FakeApi { */ public okhttp3.Call testEndpointParametersAsync(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 { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -1261,12 +973,11 @@ public class FakeApi { * @param enumQueryDouble Query parameter enum test (double) (optional) * @param enumFormStringArray Form parameter enum test (string array) (optional) * @param enumFormString Form parameter enum test (string) (optional, default to -efg) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + 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 { Object localVarPostBody = new Object(); // create path and map variables @@ -1322,27 +1033,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = testEnumParametersCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEnumParametersCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _callback); return localVarCall; } @@ -1379,7 +1078,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws ApiException { - okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null, null); + okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); return localVarApiClient.execute(localVarCall); } @@ -1400,30 +1099,11 @@ public class FakeApi { */ public okhttp3.Call testEnumParametersAsync(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } - private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -1471,24 +1151,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testGroupParametersValidateBeforeCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testGroupParametersValidateBeforeCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException { // verify the required parameter 'requiredStringGroup' is set if (requiredStringGroup == null) { @@ -1506,39 +1174,20 @@ public class FakeApi { } - okhttp3.Call localVarCall = testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _callback); return localVarCall; } private ApiResponse testGroupParametersWithHttpInfo(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws ApiException { - okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null, null); + okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null); return localVarApiClient.execute(localVarCall); } private okhttp3.Call testGroupParametersAsync(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -1594,8 +1243,8 @@ public class FakeApi { * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call buildCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { - return testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _progressListener, _progressRequestListener); + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _callback); } /** @@ -1640,12 +1289,11 @@ public class FakeApi { /** * Build call for testInlineAdditionalProperties * @param param request body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testInlineAdditionalPropertiesCall(Map param, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testInlineAdditionalPropertiesCall(Map param, final ApiCallback _callback) throws ApiException { Object localVarPostBody = param; // create path and map variables @@ -1669,24 +1317,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testInlineAdditionalPropertiesValidateBeforeCall(Map param, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testInlineAdditionalPropertiesValidateBeforeCall(Map param, final ApiCallback _callback) throws ApiException { // verify the required parameter 'param' is set if (param == null) { @@ -1694,7 +1330,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testInlineAdditionalPropertiesCall(param, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testInlineAdditionalPropertiesCall(param, _callback); return localVarCall; } @@ -1717,7 +1353,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Map param) throws ApiException { - okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, null, null); + okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, null); return localVarApiClient.execute(localVarCall); } @@ -1731,26 +1367,7 @@ public class FakeApi { */ public okhttp3.Call testInlineAdditionalPropertiesAsync(Map param, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -1758,12 +1375,11 @@ public class FakeApi { * Build call for testJsonFormData * @param param field1 (required) * @param param2 field2 (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testJsonFormDataCall(String param, String param2, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -1795,24 +1411,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testJsonFormDataValidateBeforeCall(String param, String param2, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testJsonFormDataValidateBeforeCall(String param, String param2, final ApiCallback _callback) throws ApiException { // verify the required parameter 'param' is set if (param == null) { @@ -1825,7 +1429,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testJsonFormDataCall(param, param2, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testJsonFormDataCall(param, param2, _callback); return localVarCall; } @@ -1850,7 +1454,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testJsonFormDataWithHttpInfo(String param, String param2) throws ApiException { - okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, null, null); + okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, null); return localVarApiClient.execute(localVarCall); } @@ -1865,26 +1469,7 @@ public class FakeApi { */ public okhttp3.Call testJsonFormDataAsync(String param, String param2, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 84adce504b5..96dd97bffe2 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -57,12 +57,11 @@ public class FakeClassnameTags123Api { /** * Build call for testClassname * @param body client model (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testClassnameCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -86,24 +85,12 @@ public class FakeClassnameTags123Api { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "api_key_query" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testClassnameValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testClassnameValidateBeforeCall(Client body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -111,7 +98,7 @@ public class FakeClassnameTags123Api { } - okhttp3.Call localVarCall = testClassnameCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClassnameCall(body, _callback); return localVarCall; } @@ -136,7 +123,7 @@ public class FakeClassnameTags123Api { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testClassnameWithHttpInfo(Client body) throws ApiException { - okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -151,26 +138,7 @@ public class FakeClassnameTags123Api { */ public okhttp3.Call testClassnameAsync(Client body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java index 795640173ad..eea04bb43c1 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java @@ -59,12 +59,11 @@ public class PetApi { /** * Build call for addPet * @param body Pet object that needs to be added to the store (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -88,24 +87,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call addPetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call addPetValidateBeforeCall(Pet body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -113,7 +100,7 @@ public class PetApi { } - okhttp3.Call localVarCall = addPetCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = addPetCall(body, _callback); return localVarCall; } @@ -136,7 +123,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse addPetWithHttpInfo(Pet body) throws ApiException { - okhttp3.Call localVarCall = addPetValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = addPetValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -150,26 +137,7 @@ public class PetApi { */ public okhttp3.Call addPetAsync(Pet body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = addPetValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = addPetValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -177,12 +145,11 @@ public class PetApi { * Build call for deletePet * @param petId Pet id to delete (required) * @param apiKey (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -211,24 +178,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -236,7 +191,7 @@ public class PetApi { } - okhttp3.Call localVarCall = deletePetCall(petId, apiKey, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deletePetCall(petId, apiKey, _callback); return localVarCall; } @@ -261,7 +216,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { - okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, null, null); + okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, null); return localVarApiClient.execute(localVarCall); } @@ -276,38 +231,18 @@ public class PetApi { */ public okhttp3.Call deletePetAsync(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for findPetsByStatus * @param status Status values that need to be considered for filter (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call findPetsByStatusCall(List status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -335,24 +270,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'status' is set if (status == null) { @@ -360,7 +283,7 @@ public class PetApi { } - okhttp3.Call localVarCall = findPetsByStatusCall(status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByStatusCall(status, _callback); return localVarCall; } @@ -385,7 +308,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { - okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null, null); + okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null); Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -400,26 +323,7 @@ public class PetApi { */ public okhttp3.Call findPetsByStatusAsync(List status, final ApiCallback> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, _callback); Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -427,14 +331,13 @@ public class PetApi { /** * Build call for findPetsByTags * @param tags Tags to filter by (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object * @deprecated */ @Deprecated - public okhttp3.Call findPetsByTagsCall(List tags, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call findPetsByTagsCall(List tags, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -462,25 +365,13 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final ApiCallback _callback) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { @@ -488,7 +379,7 @@ public class PetApi { } - okhttp3.Call localVarCall = findPetsByTagsCall(tags, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByTagsCall(tags, _callback); return localVarCall; } @@ -517,7 +408,7 @@ public class PetApi { */ @Deprecated public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { - okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null, null); + okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null); Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -534,26 +425,7 @@ public class PetApi { @Deprecated public okhttp3.Call findPetsByTagsAsync(List tags, final ApiCallback> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, _callback); Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -561,12 +433,11 @@ public class PetApi { /** * Build call for getPetById * @param petId ID of pet to return (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getPetByIdCall(Long petId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -591,24 +462,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "api_key" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -616,7 +475,7 @@ public class PetApi { } - okhttp3.Call localVarCall = getPetByIdCall(petId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getPetByIdCall(petId, _callback); return localVarCall; } @@ -641,7 +500,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { - okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null, null); + okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -656,26 +515,7 @@ public class PetApi { */ public okhttp3.Call getPetByIdAsync(Long petId, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -683,12 +523,11 @@ public class PetApi { /** * Build call for updatePet * @param body Pet object that needs to be added to the store (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -712,24 +551,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call updatePetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call updatePetValidateBeforeCall(Pet body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -737,7 +564,7 @@ public class PetApi { } - okhttp3.Call localVarCall = updatePetCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetCall(body, _callback); return localVarCall; } @@ -760,7 +587,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updatePetWithHttpInfo(Pet body) throws ApiException { - okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -774,26 +601,7 @@ public class PetApi { */ public okhttp3.Call updatePetAsync(Pet body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -802,12 +610,11 @@ public class PetApi { * @param petId ID of pet that needs to be updated (required) * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -840,24 +647,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -865,7 +660,7 @@ public class PetApi { } - okhttp3.Call localVarCall = updatePetWithFormCall(petId, name, status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetWithFormCall(petId, name, status, _callback); return localVarCall; } @@ -892,7 +687,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { - okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, null, null); + okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, null); return localVarApiClient.execute(localVarCall); } @@ -908,26 +703,7 @@ public class PetApi { */ public okhttp3.Call updatePetWithFormAsync(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -936,12 +712,11 @@ public class PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -974,24 +749,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -999,7 +762,7 @@ public class PetApi { } - okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, file, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, file, _callback); return localVarCall; } @@ -1028,7 +791,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { - okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, null, null); + okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1045,26 +808,7 @@ public class PetApi { */ public okhttp3.Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -1074,12 +818,11 @@ public class PetApi { * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile, String additionalMetadata, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -1112,24 +855,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFileWithRequiredFileValidateBeforeCall(Long petId, File requiredFile, String additionalMetadata, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call uploadFileWithRequiredFileValidateBeforeCall(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -1142,7 +873,7 @@ public class PetApi { } - okhttp3.Call localVarCall = uploadFileWithRequiredFileCall(petId, requiredFile, additionalMetadata, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileWithRequiredFileCall(petId, requiredFile, additionalMetadata, _callback); return localVarCall; } @@ -1171,7 +902,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File requiredFile, String additionalMetadata) throws ApiException { - okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, null, null); + okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1188,26 +919,7 @@ public class PetApi { */ public okhttp3.Call uploadFileWithRequiredFileAsync(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java index c43fecbf92a..c1be7baa130 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java @@ -57,12 +57,11 @@ public class StoreApi { /** * Build call for deleteOrder * @param orderId ID of the order that needs to be deleted (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call deleteOrderCall(String orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -87,24 +86,12 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { @@ -112,7 +99,7 @@ public class StoreApi { } - okhttp3.Call localVarCall = deleteOrderCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteOrderCall(orderId, _callback); return localVarCall; } @@ -135,7 +122,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { - okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null, null); + okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null); return localVarApiClient.execute(localVarCall); } @@ -149,37 +136,17 @@ public class StoreApi { */ public okhttp3.Call deleteOrderAsync(String orderId, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for getInventory - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getInventoryCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -203,27 +170,15 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "api_key" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getInventoryValidateBeforeCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getInventoryCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getInventoryCall(_callback); return localVarCall; } @@ -246,7 +201,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> getInventoryWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null, null); + okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null); Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -260,26 +215,7 @@ public class StoreApi { */ public okhttp3.Call getInventoryAsync(final ApiCallback> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_callback); Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -287,12 +223,11 @@ public class StoreApi { /** * Build call for getOrderById * @param orderId ID of pet that needs to be fetched (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getOrderByIdCall(Long orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -317,24 +252,12 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { @@ -342,7 +265,7 @@ public class StoreApi { } - okhttp3.Call localVarCall = getOrderByIdCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getOrderByIdCall(orderId, _callback); return localVarCall; } @@ -367,7 +290,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { - okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null, null); + okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -382,26 +305,7 @@ public class StoreApi { */ public okhttp3.Call getOrderByIdAsync(Long orderId, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -409,12 +313,11 @@ public class StoreApi { /** * Build call for placeOrder * @param body order placed for purchasing the pet (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -438,24 +341,12 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call placeOrderValidateBeforeCall(Order body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call placeOrderValidateBeforeCall(Order body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -463,7 +354,7 @@ public class StoreApi { } - okhttp3.Call localVarCall = placeOrderCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = placeOrderCall(body, _callback); return localVarCall; } @@ -488,7 +379,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse placeOrderWithHttpInfo(Order body) throws ApiException { - okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -503,26 +394,7 @@ public class StoreApi { */ public okhttp3.Call placeOrderAsync(Order body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java index 991cc2df4b7..90fbb3808a5 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java @@ -57,12 +57,11 @@ public class UserApi { /** * Build call for createUser * @param body Created user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createUserCall(User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -86,24 +85,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createUserValidateBeforeCall(User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createUserValidateBeforeCall(User body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -111,7 +98,7 @@ public class UserApi { } - okhttp3.Call localVarCall = createUserCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUserCall(body, _callback); return localVarCall; } @@ -134,7 +121,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUserWithHttpInfo(User body) throws ApiException { - okhttp3.Call localVarCall = createUserValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = createUserValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -148,38 +135,18 @@ public class UserApi { */ public okhttp3.Call createUserAsync(User body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createUserValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUserValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for createUsersWithArrayInput * @param body List of user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createUsersWithArrayInputCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createUsersWithArrayInputCall(List body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -203,24 +170,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -228,7 +183,7 @@ public class UserApi { } - okhttp3.Call localVarCall = createUsersWithArrayInputCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithArrayInputCall(body, _callback); return localVarCall; } @@ -251,7 +206,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUsersWithArrayInputWithHttpInfo(List body) throws ApiException { - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -265,38 +220,18 @@ public class UserApi { */ public okhttp3.Call createUsersWithArrayInputAsync(List body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for createUsersWithListInput * @param body List of user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createUsersWithListInputCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createUsersWithListInputCall(List body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -320,24 +255,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithListInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createUsersWithListInputValidateBeforeCall(List body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -345,7 +268,7 @@ public class UserApi { } - okhttp3.Call localVarCall = createUsersWithListInputCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithListInputCall(body, _callback); return localVarCall; } @@ -368,7 +291,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUsersWithListInputWithHttpInfo(List body) throws ApiException { - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -382,38 +305,18 @@ public class UserApi { */ public okhttp3.Call createUsersWithListInputAsync(List body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for deleteUser * @param username The name that needs to be deleted (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call deleteUserCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -438,24 +341,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteUserValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call deleteUserValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -463,7 +354,7 @@ public class UserApi { } - okhttp3.Call localVarCall = deleteUserCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteUserCall(username, _callback); return localVarCall; } @@ -486,7 +377,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { - okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null, null); + okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null); return localVarApiClient.execute(localVarCall); } @@ -500,38 +391,18 @@ public class UserApi { */ public okhttp3.Call deleteUserAsync(String username, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for getUserByName * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getUserByNameCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -556,24 +427,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -581,7 +440,7 @@ public class UserApi { } - okhttp3.Call localVarCall = getUserByNameCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getUserByNameCall(username, _callback); return localVarCall; } @@ -606,7 +465,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { - okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null, null); + okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -621,26 +480,7 @@ public class UserApi { */ public okhttp3.Call getUserByNameAsync(String username, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -649,12 +489,11 @@ public class UserApi { * Build call for loginUser * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call loginUserCall(String username, String password, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -686,24 +525,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -716,7 +543,7 @@ public class UserApi { } - okhttp3.Call localVarCall = loginUserCall(username, password, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = loginUserCall(username, password, _callback); return localVarCall; } @@ -743,7 +570,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { - okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null, null); + okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -759,38 +586,18 @@ public class UserApi { */ public okhttp3.Call loginUserAsync(String username, String password, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** * Build call for logoutUser - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call logoutUserCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -814,27 +621,15 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call logoutUserValidateBeforeCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call logoutUserValidateBeforeCall(final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = logoutUserCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = logoutUserCall(_callback); return localVarCall; } @@ -855,7 +650,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse logoutUserWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = logoutUserValidateBeforeCall(null, null); + okhttp3.Call localVarCall = logoutUserValidateBeforeCall(null); return localVarApiClient.execute(localVarCall); } @@ -868,26 +663,7 @@ public class UserApi { */ public okhttp3.Call logoutUserAsync(final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = logoutUserValidateBeforeCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = logoutUserValidateBeforeCall(_callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -895,12 +671,11 @@ public class UserApi { * Build call for updateUser * @param username name that need to be deleted (required) * @param body Updated user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call updateUserCall(String username, User body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -925,24 +700,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call updateUserValidateBeforeCall(String username, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call updateUserValidateBeforeCall(String username, User body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -955,7 +718,7 @@ public class UserApi { } - okhttp3.Call localVarCall = updateUserCall(username, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updateUserCall(username, body, _callback); return localVarCall; } @@ -980,7 +743,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updateUserWithHttpInfo(String username, User body) throws ApiException { - okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, null, null); + okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, null); return localVarApiClient.execute(localVarCall); } @@ -995,26 +758,7 @@ public class UserApi { */ public okhttp3.Call updateUserAsync(String username, User body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java index 872fb602156..719300bc985 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java @@ -35,15 +35,15 @@ public class AnotherFakeApiTest { /** * To test special tags * - * To test special tags + * To test special tags and operation ID starting with number * * @throws ApiException * if the Api call fails */ @Test - public void testSpecialTagsTest() throws ApiException { - Client client = null; - Client response = api.testSpecialTags(client); + public void call123testSpecialTagsTest() throws ApiException { + Client body = null; + Client response = api.call123testSpecialTags(body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeApiTest.java index 34e199c0cca..68036a2ef42 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -22,6 +22,7 @@ import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import org.openapitools.client.model.OuterComposite; import org.openapitools.client.model.User; +import org.openapitools.client.model.XmlItem; import org.junit.Test; import org.junit.Ignore; @@ -39,6 +40,22 @@ public class FakeApiTest { private final FakeApi api = new FakeApi(); + /** + * creates an XmlItem + * + * this route creates an XmlItem + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createXmlItemTest() throws ApiException { + XmlItem xmlItem = null; + api.createXmlItem(xmlItem); + + // TODO: test validations + } + /** * * @@ -65,8 +82,8 @@ public class FakeApiTest { */ @Test public void fakeOuterCompositeSerializeTest() throws ApiException { - OuterComposite outerComposite = null; - OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite); + OuterComposite body = null; + OuterComposite response = api.fakeOuterCompositeSerialize(body); // TODO: test validations } @@ -113,8 +130,8 @@ public class FakeApiTest { */ @Test public void testBodyWithFileSchemaTest() throws ApiException { - FileSchemaTestClass fileSchemaTestClass = null; - api.testBodyWithFileSchema(fileSchemaTestClass); + FileSchemaTestClass body = null; + api.testBodyWithFileSchema(body); // TODO: test validations } @@ -130,8 +147,8 @@ public class FakeApiTest { @Test public void testBodyWithQueryParamsTest() throws ApiException { String query = null; - User user = null; - api.testBodyWithQueryParams(query, user); + User body = null; + api.testBodyWithQueryParams(query, body); // TODO: test validations } @@ -146,8 +163,8 @@ public class FakeApiTest { */ @Test public void testClientModelTest() throws ApiException { - Client client = null; - Client response = api.testClientModel(client); + Client body = null; + Client response = api.testClientModel(body); // TODO: test validations } @@ -239,8 +256,8 @@ public class FakeApiTest { */ @Test public void testInlineAdditionalPropertiesTest() throws ApiException { - Map requestBody = null; - api.testInlineAdditionalProperties(requestBody); + Map param = null; + api.testInlineAdditionalProperties(param); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java index e2ac28cb12a..72c85cd045f 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java @@ -42,8 +42,8 @@ public class FakeClassnameTags123ApiTest { */ @Test public void testClassnameTest() throws ApiException { - Client client = null; - Client response = api.testClassname(client); + Client body = null; + Client response = api.testClassname(body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/PetApiTest.java index d3fbe90a5a6..07444455f38 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/PetApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -44,8 +44,8 @@ public class PetApiTest { */ @Test public void addPetTest() throws ApiException { - Pet pet = null; - api.addPet(pet); + Pet body = null; + api.addPet(body); // TODO: test validations } @@ -125,8 +125,8 @@ public class PetApiTest { */ @Test public void updatePetTest() throws ApiException { - Pet pet = null; - api.updatePet(pet); + Pet body = null; + api.updatePet(body); // TODO: test validations } @@ -167,4 +167,22 @@ public class PetApiTest { // TODO: test validations } + /** + * uploads an image (required) + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileWithRequiredFileTest() throws ApiException { + Long petId = null; + File requiredFile = null; + String additionalMetadata = null; + ModelApiResponse response = api.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); + + // TODO: test validations + } + } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/StoreApiTest.java index f83e6c38972..b10e977454f 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/StoreApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -89,8 +89,8 @@ public class StoreApiTest { */ @Test public void placeOrderTest() throws ApiException { - Order order = null; - Order response = api.placeOrder(order); + Order body = null; + Order response = api.placeOrder(body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/UserApiTest.java index 79e0b6b2bb5..7c392f77f99 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/UserApiTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -42,8 +42,8 @@ public class UserApiTest { */ @Test public void createUserTest() throws ApiException { - User user = null; - api.createUser(user); + User body = null; + api.createUser(body); // TODO: test validations } @@ -58,8 +58,8 @@ public class UserApiTest { */ @Test public void createUsersWithArrayInputTest() throws ApiException { - List user = null; - api.createUsersWithArrayInput(user); + List body = null; + api.createUsersWithArrayInput(body); // TODO: test validations } @@ -74,8 +74,8 @@ public class UserApiTest { */ @Test public void createUsersWithListInputTest() throws ApiException { - List user = null; - api.createUsersWithListInput(user); + List body = null; + api.createUsersWithListInput(body); // TODO: test validations } @@ -155,8 +155,8 @@ public class UserApiTest { @Test public void updateUserTest() throws ApiException { String username = null; - User user = null; - api.updateUser(username, user); + User body = null; + api.updateUser(username, body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java index a9fe469fe71..c8916e7cf35 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java @@ -124,7 +124,9 @@ public class ApiClient { } private void init() { - httpClient = new OkHttpClient(); + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addInterceptor(getProgressInterceptor()); + httpClient = builder.build(); verifyingSsl = true; @@ -173,7 +175,7 @@ public class ApiClient { * @return Api Client */ public ApiClient setHttpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; + this.httpClient = httpClient.newBuilder().addInterceptor(getProgressInterceptor()).build(); return this; } @@ -1032,12 +1034,12 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP call * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener); + public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, callback); return httpClient.newCall(request); } @@ -1053,11 +1055,11 @@ public class ApiClient { * @param headerParams The header parameters * @param formParams The form parameters * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener + * @param callback Callback for upload/download progress * @return The HTTP request * @throws 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 formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); final String url = buildUrl(path, queryParams, collectionQueryParams); @@ -1089,10 +1091,14 @@ public class ApiClient { reqBody = serialize(body, contentType); } + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + Request request = null; - if (progressRequestListener != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener); + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); request = reqBuilder.method(method, progressRequestBody).build(); } else { request = reqBuilder.method(method, reqBody).build(); @@ -1236,6 +1242,27 @@ public class ApiClient { } } + /** + * 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. diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java index f33edde76b8..1e3e1aff6ae 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressRequestBody.java @@ -26,17 +26,13 @@ import okio.Sink; public class ProgressRequestBody extends RequestBody { - public interface ProgressRequestListener { - void onRequestProgress(long bytesWritten, long contentLength, boolean done); - } - private final RequestBody requestBody; - private final ProgressRequestListener progressListener; + private final ApiCallback callback; - public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) { + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { this.requestBody = requestBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -70,7 +66,7 @@ public class ProgressRequestBody extends RequestBody { } bytesWritten += byteCount; - progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength); + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); } }; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java index 258e48eceb4..f9ddfbd35ac 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ProgressResponseBody.java @@ -26,17 +26,13 @@ import okio.Source; public class ProgressResponseBody extends ResponseBody { - public interface ProgressListener { - void update(long bytesRead, long contentLength, boolean done); - } - private final ResponseBody responseBody; - private final ProgressListener progressListener; + private final ApiCallback callback; private BufferedSource bufferedSource; - public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) { + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { this.responseBody = responseBody; - this.progressListener = progressListener; + this.callback = callback; } @Override @@ -66,7 +62,7 @@ public class ProgressResponseBody extends ResponseBody { 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; - progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); return bytesRead; } }; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 49f4e834540..c5392ad57ba 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -57,12 +57,11 @@ public class AnotherFakeApi { /** * Build call for call123testSpecialTags * @param body client model (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call call123testSpecialTagsCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -86,24 +85,12 @@ public class AnotherFakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call call123testSpecialTagsValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call call123testSpecialTagsValidateBeforeCall(Client body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -111,7 +98,7 @@ public class AnotherFakeApi { } - okhttp3.Call localVarCall = call123testSpecialTagsCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = call123testSpecialTagsCall(body, _callback); return localVarCall; } @@ -136,7 +123,7 @@ public class AnotherFakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse call123testSpecialTagsWithHttpInfo(Client body) throws ApiException { - okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -151,26 +138,7 @@ public class AnotherFakeApi { */ public okhttp3.Call call123testSpecialTagsAsync(Client body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java index d1fcd2043e4..a1a5d500323 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java @@ -65,12 +65,11 @@ public class FakeApi { /** * Build call for createXmlItem * @param xmlItem XmlItem Body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callback) throws ApiException { Object localVarPostBody = xmlItem; // create path and map variables @@ -94,24 +93,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createXmlItemValidateBeforeCall(XmlItem xmlItem, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createXmlItemValidateBeforeCall(XmlItem xmlItem, final ApiCallback _callback) throws ApiException { // verify the required parameter 'xmlItem' is set if (xmlItem == null) { @@ -119,7 +106,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = createXmlItemCall(xmlItem, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createXmlItemCall(xmlItem, _callback); return localVarCall; } @@ -142,7 +129,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createXmlItemWithHttpInfo(XmlItem xmlItem) throws ApiException { - okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, null, null); + okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, null); return localVarApiClient.execute(localVarCall); } @@ -156,38 +143,18 @@ public class FakeApi { */ public okhttp3.Call createXmlItemAsync(XmlItem xmlItem, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createXmlItemValidateBeforeCall(xmlItem, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for fakeOuterBooleanSerialize * @param body Input boolean as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -211,27 +178,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterBooleanSerializeValidateBeforeCall(Boolean body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterBooleanSerializeValidateBeforeCall(Boolean body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterBooleanSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterBooleanSerializeCall(body, _callback); return localVarCall; } @@ -256,7 +211,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -271,26 +226,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterBooleanSerializeAsync(Boolean body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -298,12 +234,11 @@ public class FakeApi { /** * Build call for fakeOuterCompositeSerialize * @param body Input composite as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -327,27 +262,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterCompositeSerializeValidateBeforeCall(OuterComposite body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterCompositeSerializeValidateBeforeCall(OuterComposite body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterCompositeSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterCompositeSerializeCall(body, _callback); return localVarCall; } @@ -372,7 +295,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -387,26 +310,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterCompositeSerializeAsync(OuterComposite body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -414,12 +318,11 @@ public class FakeApi { /** * Build call for fakeOuterNumberSerialize * @param body Input number as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -443,27 +346,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterNumberSerializeValidateBeforeCall(BigDecimal body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterNumberSerializeValidateBeforeCall(BigDecimal body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterNumberSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterNumberSerializeCall(body, _callback); return localVarCall; } @@ -488,7 +379,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -503,26 +394,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterNumberSerializeAsync(BigDecimal body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -530,12 +402,11 @@ public class FakeApi { /** * Build call for fakeOuterStringSerialize * @param body Input string as post body (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call fakeOuterStringSerializeCall(String body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -559,27 +430,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call fakeOuterStringSerializeValidateBeforeCall(String body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call fakeOuterStringSerializeValidateBeforeCall(String body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = fakeOuterStringSerializeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterStringSerializeCall(body, _callback); return localVarCall; } @@ -604,7 +463,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse fakeOuterStringSerializeWithHttpInfo(String body) throws ApiException { - okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -619,26 +478,7 @@ public class FakeApi { */ public okhttp3.Call fakeOuterStringSerializeAsync(String body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -646,12 +486,11 @@ public class FakeApi { /** * Build call for testBodyWithFileSchema * @param body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -675,24 +514,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testBodyWithFileSchemaValidateBeforeCall(FileSchemaTestClass body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testBodyWithFileSchemaValidateBeforeCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -700,7 +527,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testBodyWithFileSchemaCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithFileSchemaCall(body, _callback); return localVarCall; } @@ -723,7 +550,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass body) throws ApiException { - okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -737,26 +564,7 @@ public class FakeApi { */ public okhttp3.Call testBodyWithFileSchemaAsync(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithFileSchemaValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -764,12 +572,11 @@ public class FakeApi { * Build call for testBodyWithQueryParams * @param query (required) * @param body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -797,24 +604,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testBodyWithQueryParamsValidateBeforeCall(String query, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testBodyWithQueryParamsValidateBeforeCall(String query, User body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'query' is set if (query == null) { @@ -827,7 +622,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testBodyWithQueryParamsCall(query, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithQueryParamsCall(query, body, _callback); return localVarCall; } @@ -852,7 +647,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testBodyWithQueryParamsWithHttpInfo(String query, User body) throws ApiException { - okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, null, null); + okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, null); return localVarApiClient.execute(localVarCall); } @@ -867,38 +662,18 @@ public class FakeApi { */ public okhttp3.Call testBodyWithQueryParamsAsync(String query, User body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testBodyWithQueryParamsValidateBeforeCall(query, body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for testClientModel * @param body client model (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testClientModelCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -922,24 +697,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testClientModelValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testClientModelValidateBeforeCall(Client body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -947,7 +710,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testClientModelCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClientModelCall(body, _callback); return localVarCall; } @@ -972,7 +735,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testClientModelWithHttpInfo(Client body) throws ApiException { - okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -987,26 +750,7 @@ public class FakeApi { */ public okhttp3.Call testClientModelAsync(Client body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -1027,12 +771,11 @@ public class FakeApi { * @param dateTime None (optional) * @param password None (optional) * @param paramCallback None (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - 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 ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + 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 { Object localVarPostBody = new Object(); // create path and map variables @@ -1112,24 +855,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "http_basic_test" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testEndpointParametersValidateBeforeCall(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 ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testEndpointParametersValidateBeforeCall(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 { // verify the required parameter 'number' is set if (number == null) { @@ -1152,7 +883,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testEndpointParametersCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEndpointParametersCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _callback); return localVarCall; } @@ -1201,7 +932,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testEndpointParametersWithHttpInfo(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) throws ApiException { - okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null, null); + okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null); return localVarApiClient.execute(localVarCall); } @@ -1228,26 +959,7 @@ public class FakeApi { */ public okhttp3.Call testEndpointParametersAsync(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 { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEndpointParametersValidateBeforeCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -1261,12 +973,11 @@ public class FakeApi { * @param enumQueryDouble Query parameter enum test (double) (optional) * @param enumFormStringArray Form parameter enum test (string array) (optional) * @param enumFormString Form parameter enum test (string) (optional, default to -efg) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + 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 { Object localVarPostBody = new Object(); // create path and map variables @@ -1322,27 +1033,15 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = testEnumParametersCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEnumParametersCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _callback); return localVarCall; } @@ -1379,7 +1078,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws ApiException { - okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null, null); + okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); return localVarApiClient.execute(localVarCall); } @@ -1400,30 +1099,11 @@ public class FakeApi { */ public okhttp3.Call testEnumParametersAsync(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } - private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -1471,24 +1151,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testGroupParametersValidateBeforeCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testGroupParametersValidateBeforeCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException { // verify the required parameter 'requiredStringGroup' is set if (requiredStringGroup == null) { @@ -1506,39 +1174,20 @@ public class FakeApi { } - okhttp3.Call localVarCall = testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _callback); return localVarCall; } private ApiResponse testGroupParametersWithHttpInfo(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws ApiException { - okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null, null); + okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null); return localVarApiClient.execute(localVarCall); } private okhttp3.Call testGroupParametersAsync(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testGroupParametersValidateBeforeCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -1594,8 +1243,8 @@ public class FakeApi { * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call buildCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { - return testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _progressListener, _progressRequestListener); + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return testGroupParametersCall(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, _callback); } /** @@ -1640,12 +1289,11 @@ public class FakeApi { /** * Build call for testInlineAdditionalProperties * @param param request body (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testInlineAdditionalPropertiesCall(Map param, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testInlineAdditionalPropertiesCall(Map param, final ApiCallback _callback) throws ApiException { Object localVarPostBody = param; // create path and map variables @@ -1669,24 +1317,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testInlineAdditionalPropertiesValidateBeforeCall(Map param, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testInlineAdditionalPropertiesValidateBeforeCall(Map param, final ApiCallback _callback) throws ApiException { // verify the required parameter 'param' is set if (param == null) { @@ -1694,7 +1330,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testInlineAdditionalPropertiesCall(param, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testInlineAdditionalPropertiesCall(param, _callback); return localVarCall; } @@ -1717,7 +1353,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Map param) throws ApiException { - okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, null, null); + okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, null); return localVarApiClient.execute(localVarCall); } @@ -1731,26 +1367,7 @@ public class FakeApi { */ public okhttp3.Call testInlineAdditionalPropertiesAsync(Map param, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testInlineAdditionalPropertiesValidateBeforeCall(param, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -1758,12 +1375,11 @@ public class FakeApi { * Build call for testJsonFormData * @param param field1 (required) * @param param2 field2 (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testJsonFormDataCall(String param, String param2, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -1795,24 +1411,12 @@ public class FakeApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testJsonFormDataValidateBeforeCall(String param, String param2, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testJsonFormDataValidateBeforeCall(String param, String param2, final ApiCallback _callback) throws ApiException { // verify the required parameter 'param' is set if (param == null) { @@ -1825,7 +1429,7 @@ public class FakeApi { } - okhttp3.Call localVarCall = testJsonFormDataCall(param, param2, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testJsonFormDataCall(param, param2, _callback); return localVarCall; } @@ -1850,7 +1454,7 @@ public class FakeApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testJsonFormDataWithHttpInfo(String param, String param2) throws ApiException { - okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, null, null); + okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, null); return localVarApiClient.execute(localVarCall); } @@ -1865,26 +1469,7 @@ public class FakeApi { */ public okhttp3.Call testJsonFormDataAsync(String param, String param2, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testJsonFormDataValidateBeforeCall(param, param2, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 84adce504b5..96dd97bffe2 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -57,12 +57,11 @@ public class FakeClassnameTags123Api { /** * Build call for testClassname * @param body client model (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call testClassnameCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -86,24 +85,12 @@ public class FakeClassnameTags123Api { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "api_key_query" }; - return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call testClassnameValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call testClassnameValidateBeforeCall(Client body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -111,7 +98,7 @@ public class FakeClassnameTags123Api { } - okhttp3.Call localVarCall = testClassnameCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClassnameCall(body, _callback); return localVarCall; } @@ -136,7 +123,7 @@ public class FakeClassnameTags123Api { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse testClassnameWithHttpInfo(Client body) throws ApiException { - okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -151,26 +138,7 @@ public class FakeClassnameTags123Api { */ public okhttp3.Call testClassnameAsync(Client body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java index 795640173ad..eea04bb43c1 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java @@ -59,12 +59,11 @@ public class PetApi { /** * Build call for addPet * @param body Pet object that needs to be added to the store (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -88,24 +87,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call addPetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call addPetValidateBeforeCall(Pet body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -113,7 +100,7 @@ public class PetApi { } - okhttp3.Call localVarCall = addPetCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = addPetCall(body, _callback); return localVarCall; } @@ -136,7 +123,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse addPetWithHttpInfo(Pet body) throws ApiException { - okhttp3.Call localVarCall = addPetValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = addPetValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -150,26 +137,7 @@ public class PetApi { */ public okhttp3.Call addPetAsync(Pet body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = addPetValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = addPetValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -177,12 +145,11 @@ public class PetApi { * Build call for deletePet * @param petId Pet id to delete (required) * @param apiKey (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -211,24 +178,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -236,7 +191,7 @@ public class PetApi { } - okhttp3.Call localVarCall = deletePetCall(petId, apiKey, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deletePetCall(petId, apiKey, _callback); return localVarCall; } @@ -261,7 +216,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { - okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, null, null); + okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, null); return localVarApiClient.execute(localVarCall); } @@ -276,38 +231,18 @@ public class PetApi { */ public okhttp3.Call deletePetAsync(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for findPetsByStatus * @param status Status values that need to be considered for filter (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call findPetsByStatusCall(List status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -335,24 +270,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'status' is set if (status == null) { @@ -360,7 +283,7 @@ public class PetApi { } - okhttp3.Call localVarCall = findPetsByStatusCall(status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByStatusCall(status, _callback); return localVarCall; } @@ -385,7 +308,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { - okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null, null); + okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null); Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -400,26 +323,7 @@ public class PetApi { */ public okhttp3.Call findPetsByStatusAsync(List status, final ApiCallback> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, _callback); Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -427,14 +331,13 @@ public class PetApi { /** * Build call for findPetsByTags * @param tags Tags to filter by (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object * @deprecated */ @Deprecated - public okhttp3.Call findPetsByTagsCall(List tags, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call findPetsByTagsCall(List tags, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -462,25 +365,13 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final ApiCallback _callback) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { @@ -488,7 +379,7 @@ public class PetApi { } - okhttp3.Call localVarCall = findPetsByTagsCall(tags, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByTagsCall(tags, _callback); return localVarCall; } @@ -517,7 +408,7 @@ public class PetApi { */ @Deprecated public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { - okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null, null); + okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null); Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -534,26 +425,7 @@ public class PetApi { @Deprecated public okhttp3.Call findPetsByTagsAsync(List tags, final ApiCallback> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, _callback); Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -561,12 +433,11 @@ public class PetApi { /** * Build call for getPetById * @param petId ID of pet to return (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getPetByIdCall(Long petId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -591,24 +462,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "api_key" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -616,7 +475,7 @@ public class PetApi { } - okhttp3.Call localVarCall = getPetByIdCall(petId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getPetByIdCall(petId, _callback); return localVarCall; } @@ -641,7 +500,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { - okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null, null); + okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -656,26 +515,7 @@ public class PetApi { */ public okhttp3.Call getPetByIdAsync(Long petId, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -683,12 +523,11 @@ public class PetApi { /** * Build call for updatePet * @param body Pet object that needs to be added to the store (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -712,24 +551,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call updatePetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call updatePetValidateBeforeCall(Pet body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -737,7 +564,7 @@ public class PetApi { } - okhttp3.Call localVarCall = updatePetCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetCall(body, _callback); return localVarCall; } @@ -760,7 +587,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updatePetWithHttpInfo(Pet body) throws ApiException { - okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -774,26 +601,7 @@ public class PetApi { */ public okhttp3.Call updatePetAsync(Pet body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -802,12 +610,11 @@ public class PetApi { * @param petId ID of pet that needs to be updated (required) * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -840,24 +647,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -865,7 +660,7 @@ public class PetApi { } - okhttp3.Call localVarCall = updatePetWithFormCall(petId, name, status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetWithFormCall(petId, name, status, _callback); return localVarCall; } @@ -892,7 +687,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { - okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, null, null); + okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, null); return localVarApiClient.execute(localVarCall); } @@ -908,26 +703,7 @@ public class PetApi { */ public okhttp3.Call updatePetWithFormAsync(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -936,12 +712,11 @@ public class PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -974,24 +749,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -999,7 +762,7 @@ public class PetApi { } - okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, file, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, file, _callback); return localVarCall; } @@ -1028,7 +791,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { - okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, null, null); + okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1045,26 +808,7 @@ public class PetApi { */ public okhttp3.Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -1074,12 +818,11 @@ public class PetApi { * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile, String additionalMetadata, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -1112,24 +855,12 @@ public class PetApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFileWithRequiredFileValidateBeforeCall(Long petId, File requiredFile, String additionalMetadata, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call uploadFileWithRequiredFileValidateBeforeCall(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { @@ -1142,7 +873,7 @@ public class PetApi { } - okhttp3.Call localVarCall = uploadFileWithRequiredFileCall(petId, requiredFile, additionalMetadata, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileWithRequiredFileCall(petId, requiredFile, additionalMetadata, _callback); return localVarCall; } @@ -1171,7 +902,7 @@ public class PetApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long petId, File requiredFile, String additionalMetadata) throws ApiException { - okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, null, null); + okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1188,26 +919,7 @@ public class PetApi { */ public okhttp3.Call uploadFileWithRequiredFileAsync(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java index c43fecbf92a..c1be7baa130 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java @@ -57,12 +57,11 @@ public class StoreApi { /** * Build call for deleteOrder * @param orderId ID of the order that needs to be deleted (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call deleteOrderCall(String orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -87,24 +86,12 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { @@ -112,7 +99,7 @@ public class StoreApi { } - okhttp3.Call localVarCall = deleteOrderCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteOrderCall(orderId, _callback); return localVarCall; } @@ -135,7 +122,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { - okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null, null); + okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null); return localVarApiClient.execute(localVarCall); } @@ -149,37 +136,17 @@ public class StoreApi { */ public okhttp3.Call deleteOrderAsync(String orderId, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for getInventory - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getInventoryCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -203,27 +170,15 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { "api_key" }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getInventoryValidateBeforeCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getInventoryCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getInventoryCall(_callback); return localVarCall; } @@ -246,7 +201,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> getInventoryWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null, null); + okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null); Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -260,26 +215,7 @@ public class StoreApi { */ public okhttp3.Call getInventoryAsync(final ApiCallback> _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_callback); Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -287,12 +223,11 @@ public class StoreApi { /** * Build call for getOrderById * @param orderId ID of pet that needs to be fetched (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getOrderByIdCall(Long orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -317,24 +252,12 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { @@ -342,7 +265,7 @@ public class StoreApi { } - okhttp3.Call localVarCall = getOrderByIdCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getOrderByIdCall(orderId, _callback); return localVarCall; } @@ -367,7 +290,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { - okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null, null); + okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -382,26 +305,7 @@ public class StoreApi { */ public okhttp3.Call getOrderByIdAsync(Long orderId, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -409,12 +313,11 @@ public class StoreApi { /** * Build call for placeOrder * @param body order placed for purchasing the pet (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -438,24 +341,12 @@ public class StoreApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call placeOrderValidateBeforeCall(Order body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call placeOrderValidateBeforeCall(Order body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -463,7 +354,7 @@ public class StoreApi { } - okhttp3.Call localVarCall = placeOrderCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = placeOrderCall(body, _callback); return localVarCall; } @@ -488,7 +379,7 @@ public class StoreApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse placeOrderWithHttpInfo(Order body) throws ApiException { - okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -503,26 +394,7 @@ public class StoreApi { */ public okhttp3.Call placeOrderAsync(Order body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java index 991cc2df4b7..90fbb3808a5 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java @@ -57,12 +57,11 @@ public class UserApi { /** * Build call for createUser * @param body Created user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createUserCall(User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -86,24 +85,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createUserValidateBeforeCall(User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createUserValidateBeforeCall(User body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -111,7 +98,7 @@ public class UserApi { } - okhttp3.Call localVarCall = createUserCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUserCall(body, _callback); return localVarCall; } @@ -134,7 +121,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUserWithHttpInfo(User body) throws ApiException { - okhttp3.Call localVarCall = createUserValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = createUserValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -148,38 +135,18 @@ public class UserApi { */ public okhttp3.Call createUserAsync(User body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createUserValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUserValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for createUsersWithArrayInput * @param body List of user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createUsersWithArrayInputCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createUsersWithArrayInputCall(List body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -203,24 +170,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -228,7 +183,7 @@ public class UserApi { } - okhttp3.Call localVarCall = createUsersWithArrayInputCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithArrayInputCall(body, _callback); return localVarCall; } @@ -251,7 +206,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUsersWithArrayInputWithHttpInfo(List body) throws ApiException { - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -265,38 +220,18 @@ public class UserApi { */ public okhttp3.Call createUsersWithArrayInputAsync(List body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for createUsersWithListInput * @param body List of user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call createUsersWithListInputCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call createUsersWithListInputCall(List body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -320,24 +255,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithListInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call createUsersWithListInputValidateBeforeCall(List body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'body' is set if (body == null) { @@ -345,7 +268,7 @@ public class UserApi { } - okhttp3.Call localVarCall = createUsersWithListInputCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithListInputCall(body, _callback); return localVarCall; } @@ -368,7 +291,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUsersWithListInputWithHttpInfo(List body) throws ApiException { - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null, null); + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } @@ -382,38 +305,18 @@ public class UserApi { */ public okhttp3.Call createUsersWithListInputAsync(List body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for deleteUser * @param username The name that needs to be deleted (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call deleteUserCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -438,24 +341,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteUserValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call deleteUserValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -463,7 +354,7 @@ public class UserApi { } - okhttp3.Call localVarCall = deleteUserCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteUserCall(username, _callback); return localVarCall; } @@ -486,7 +377,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { - okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null, null); + okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null); return localVarApiClient.execute(localVarCall); } @@ -500,38 +391,18 @@ public class UserApi { */ public okhttp3.Call deleteUserAsync(String username, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for getUserByName * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call getUserByNameCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -556,24 +427,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -581,7 +440,7 @@ public class UserApi { } - okhttp3.Call localVarCall = getUserByNameCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getUserByNameCall(username, _callback); return localVarCall; } @@ -606,7 +465,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { - okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null, null); + okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -621,26 +480,7 @@ public class UserApi { */ public okhttp3.Call getUserByNameAsync(String username, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -649,12 +489,11 @@ public class UserApi { * Build call for loginUser * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call loginUserCall(String username, String password, final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -686,24 +525,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -716,7 +543,7 @@ public class UserApi { } - okhttp3.Call localVarCall = loginUserCall(username, password, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = loginUserCall(username, password, _callback); return localVarCall; } @@ -743,7 +570,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { - okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null, null); + okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -759,38 +586,18 @@ public class UserApi { */ public okhttp3.Call loginUserAsync(String username, String password, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** * Build call for logoutUser - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call logoutUserCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiException { Object localVarPostBody = new Object(); // create path and map variables @@ -814,27 +621,15 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call logoutUserValidateBeforeCall(final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call logoutUserValidateBeforeCall(final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = logoutUserCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = logoutUserCall(_callback); return localVarCall; } @@ -855,7 +650,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse logoutUserWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = logoutUserValidateBeforeCall(null, null); + okhttp3.Call localVarCall = logoutUserValidateBeforeCall(null); return localVarApiClient.execute(localVarCall); } @@ -868,26 +663,7 @@ public class UserApi { */ public okhttp3.Call logoutUserAsync(final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = logoutUserValidateBeforeCall(_progressListener, _progressRequestListener); + okhttp3.Call localVarCall = logoutUserValidateBeforeCall(_callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -895,12 +671,11 @@ public class UserApi { * Build call for updateUser * @param username name that need to be deleted (required) * @param body Updated user object (required) - * @param _progressListener Progress listener - * @param _progressRequestListener Progress request listener + * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - public okhttp3.Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + public okhttp3.Call updateUserCall(String username, User body, final ApiCallback _callback) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -925,24 +700,12 @@ public class UserApi { final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); - if (_progressListener != null) { - localVarApiClient.setHttpClient(localVarApiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { - @Override - public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { - okhttp3.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), _progressListener)) - .build(); - } - }).build()); - } - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _progressRequestListener); + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call updateUserValidateBeforeCall(String username, User body, final ProgressResponseBody.ProgressListener _progressListener, final ProgressRequestBody.ProgressRequestListener _progressRequestListener) throws ApiException { + private okhttp3.Call updateUserValidateBeforeCall(String username, User body, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { @@ -955,7 +718,7 @@ public class UserApi { } - okhttp3.Call localVarCall = updateUserCall(username, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updateUserCall(username, body, _callback); return localVarCall; } @@ -980,7 +743,7 @@ public class UserApi { * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updateUserWithHttpInfo(String username, User body) throws ApiException { - okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, null, null); + okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, null); return localVarApiClient.execute(localVarCall); } @@ -995,26 +758,7 @@ public class UserApi { */ public okhttp3.Call updateUserAsync(String username, User body, final ApiCallback _callback) throws ApiException { - ProgressResponseBody.ProgressListener _progressListener = null; - ProgressRequestBody.ProgressRequestListener _progressRequestListener = null; - - if (_callback != null) { - _progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - _callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - _progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - _callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, _progressListener, _progressRequestListener); + okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java index b6db8d2a2c3..719300bc985 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/AnotherFakeApiTest.java @@ -42,8 +42,8 @@ public class AnotherFakeApiTest { */ @Test public void call123testSpecialTagsTest() throws ApiException { - Client client = null; - Client response = api.call123testSpecialTags(client); + Client body = null; + Client response = api.call123testSpecialTags(body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java index 34e199c0cca..68036a2ef42 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -22,6 +22,7 @@ import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import org.openapitools.client.model.OuterComposite; import org.openapitools.client.model.User; +import org.openapitools.client.model.XmlItem; import org.junit.Test; import org.junit.Ignore; @@ -39,6 +40,22 @@ public class FakeApiTest { private final FakeApi api = new FakeApi(); + /** + * creates an XmlItem + * + * this route creates an XmlItem + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createXmlItemTest() throws ApiException { + XmlItem xmlItem = null; + api.createXmlItem(xmlItem); + + // TODO: test validations + } + /** * * @@ -65,8 +82,8 @@ public class FakeApiTest { */ @Test public void fakeOuterCompositeSerializeTest() throws ApiException { - OuterComposite outerComposite = null; - OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite); + OuterComposite body = null; + OuterComposite response = api.fakeOuterCompositeSerialize(body); // TODO: test validations } @@ -113,8 +130,8 @@ public class FakeApiTest { */ @Test public void testBodyWithFileSchemaTest() throws ApiException { - FileSchemaTestClass fileSchemaTestClass = null; - api.testBodyWithFileSchema(fileSchemaTestClass); + FileSchemaTestClass body = null; + api.testBodyWithFileSchema(body); // TODO: test validations } @@ -130,8 +147,8 @@ public class FakeApiTest { @Test public void testBodyWithQueryParamsTest() throws ApiException { String query = null; - User user = null; - api.testBodyWithQueryParams(query, user); + User body = null; + api.testBodyWithQueryParams(query, body); // TODO: test validations } @@ -146,8 +163,8 @@ public class FakeApiTest { */ @Test public void testClientModelTest() throws ApiException { - Client client = null; - Client response = api.testClientModel(client); + Client body = null; + Client response = api.testClientModel(body); // TODO: test validations } @@ -239,8 +256,8 @@ public class FakeApiTest { */ @Test public void testInlineAdditionalPropertiesTest() throws ApiException { - Map requestBody = null; - api.testInlineAdditionalProperties(requestBody); + Map param = null; + api.testInlineAdditionalProperties(param); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java index e2ac28cb12a..72c85cd045f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeClassnameTags123ApiTest.java @@ -42,8 +42,8 @@ public class FakeClassnameTags123ApiTest { */ @Test public void testClassnameTest() throws ApiException { - Client client = null; - Client response = api.testClassname(client); + Client body = null; + Client response = api.testClassname(body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/StoreApiTest.java index f83e6c38972..b10e977454f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/StoreApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -89,8 +89,8 @@ public class StoreApiTest { */ @Test public void placeOrderTest() throws ApiException { - Order order = null; - Order response = api.placeOrder(order); + Order body = null; + Order response = api.placeOrder(body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/UserApiTest.java index 79e0b6b2bb5..7c392f77f99 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/UserApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -42,8 +42,8 @@ public class UserApiTest { */ @Test public void createUserTest() throws ApiException { - User user = null; - api.createUser(user); + User body = null; + api.createUser(body); // TODO: test validations } @@ -58,8 +58,8 @@ public class UserApiTest { */ @Test public void createUsersWithArrayInputTest() throws ApiException { - List user = null; - api.createUsersWithArrayInput(user); + List body = null; + api.createUsersWithArrayInput(body); // TODO: test validations } @@ -74,8 +74,8 @@ public class UserApiTest { */ @Test public void createUsersWithListInputTest() throws ApiException { - List user = null; - api.createUsersWithListInput(user); + List body = null; + api.createUsersWithListInput(body); // TODO: test validations } @@ -155,8 +155,8 @@ public class UserApiTest { @Test public void updateUserTest() throws ApiException { String username = null; - User user = null; - api.updateUser(username, user); + User body = null; + api.updateUser(username, body); // TODO: test validations } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/XmlItemTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/XmlItemTest.java index 5e861e18621..7ecbaf4fa98 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/XmlItemTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/XmlItemTest.java @@ -228,51 +228,51 @@ public class XmlItemTest { } /** - * Test the property 'prefixNamespaceString' + * Test the property 'prefixNsString' */ @Test - public void prefixNamespaceStringTest() { - // TODO: test prefixNamespaceString + public void prefixNsStringTest() { + // TODO: test prefixNsString } /** - * Test the property 'prefixNamespaceNumber' + * Test the property 'prefixNsNumber' */ @Test - public void prefixNamespaceNumberTest() { - // TODO: test prefixNamespaceNumber + public void prefixNsNumberTest() { + // TODO: test prefixNsNumber } /** - * Test the property 'prefixNamespaceInteger' + * Test the property 'prefixNsInteger' */ @Test - public void prefixNamespaceIntegerTest() { - // TODO: test prefixNamespaceInteger + public void prefixNsIntegerTest() { + // TODO: test prefixNsInteger } /** - * Test the property 'prefixNamespaceBoolean' + * Test the property 'prefixNsBoolean' */ @Test - public void prefixNamespaceBooleanTest() { - // TODO: test prefixNamespaceBoolean + public void prefixNsBooleanTest() { + // TODO: test prefixNsBoolean } /** - * Test the property 'prefixNamespaceArray' + * Test the property 'prefixNsArray' */ @Test - public void prefixNamespaceArrayTest() { - // TODO: test prefixNamespaceArray + public void prefixNsArrayTest() { + // TODO: test prefixNsArray } /** - * Test the property 'prefixNamespaceWrappedArray' + * Test the property 'prefixNsWrappedArray' */ @Test - public void prefixNamespaceWrappedArrayTest() { - // TODO: test prefixNamespaceWrappedArray + public void prefixNsWrappedArrayTest() { + // TODO: test prefixNsWrappedArray } }