-
Notifications
You must be signed in to change notification settings - Fork 6k
[JAVA/okhttp-json] some errors in api.mustache template in relation to localVariablePrefix #10351
Copy link
Copy link
Closed
Description
Description
There are a few unresolved variables in the api.mustache template:
callback should NOT have prefix since it is not a local variable:
swagger-codegen/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache
Lines 222 to 265 in bdb4edd
| /** | |
| * {{summary}} (asynchronously) | |
| * {{notes}}{{#allParams}} | |
| * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} | |
| * @param callback The callback to be executed when the API call finishes | |
| * @return The request call | |
| * @throws ApiException If fail to process the API call, e.g. serializing the request body object | |
| {{#isDeprecated}} | |
| * @deprecated | |
| {{/isDeprecated}} | |
| {{#externalDocs}} | |
| * {{description}} | |
| * @see <a href="{{url}}">{{summary}} Documentation</a> | |
| {{/externalDocs}} | |
| */ | |
| {{#isDeprecated}} | |
| @Deprecated | |
| {{/isDeprecated}} | |
| public com.squareup.okhttp.Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}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 {{localVariablePrefix}}call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener); | |
| {{#returnType}}Type {{localVariablePrefix}}localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType(); | |
| {{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}localVarReturnType, {{localVariablePrefix}}callback);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}callback);{{/returnType}} | |
| return {{localVariablePrefix}}call; | |
| } |
apiClient is missing prefix here:
swagger-codegen/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache
Line 117 in bdb4edd
| apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
Suggest a fix/enhancement
I fixed the template locally. Will make a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels