forked from loafle/openapi-generator-original
Escape model name in Java okhttp-gson client
This commit is contained in:
parent
f10d4c8e23
commit
a3f57d6cbd
@ -61,6 +61,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"localVarPath", "localVarQueryParams", "localVarHeaderParams", "localVarFormParams",
|
||||
"localVarPostBody", "localVarAccepts", "localVarAccept", "localVarContentTypes",
|
||||
"localVarContentType", "localVarAuthNames", "localReturnType",
|
||||
"ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil",
|
||||
|
||||
// language reserved words
|
||||
"abstract", "continue", "for", "new", "switch", "assert",
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
# ModelApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **Integer** | | [optional]
|
||||
**type** | **String** | | [optional]
|
||||
**message** | **String** | | [optional]
|
||||
|
||||
|
||||
|
@ -391,7 +391,7 @@ null (empty response body)
|
||||
|
||||
<a name="uploadFile"></a>
|
||||
# **uploadFile**
|
||||
> ApiResponse uploadFile(petId, additionalMetadata, file)
|
||||
> ModelApiResponse uploadFile(petId, additionalMetadata, file)
|
||||
|
||||
uploads an image
|
||||
|
||||
@ -417,7 +417,7 @@ Long petId = 789L; // Long | ID of pet to update
|
||||
String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server
|
||||
File file = new File("/path/to/file.txt"); // File | file to upload
|
||||
try {
|
||||
ApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file);
|
||||
ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling PetApi#uploadFile");
|
||||
@ -435,7 +435,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
[**ModelApiResponse**](ModelApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
@ -146,12 +146,7 @@ public class ApiClient {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));
|
||||
authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret"));
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("test_http_basic", new HttpBasicAuth());
|
||||
authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query"));
|
||||
authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:59.477+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:59.477+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:59.477+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00")
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:59.477+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -18,8 +18,8 @@ import com.squareup.okhttp.Response;
|
||||
import java.io.IOException;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import io.swagger.client.model.ModelApiResponse;
|
||||
import java.io.File;
|
||||
import io.swagger.client.model.ApiResponse;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
@ -852,11 +852,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)
|
||||
* @return ApiResponse
|
||||
* @return ModelApiResponse
|
||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||
*/
|
||||
public ApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
ApiResponse<ApiResponse> resp = uploadFileWithHttpInfo(petId, additionalMetadata, file);
|
||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
ApiResponse<ModelApiResponse> resp = uploadFileWithHttpInfo(petId, additionalMetadata, file);
|
||||
return resp.getData();
|
||||
}
|
||||
|
||||
@ -866,12 +866,12 @@ 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)
|
||||
* @return ApiResponse<ApiResponse>
|
||||
* @return ApiResponse<ModelApiResponse>
|
||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||
*/
|
||||
public ApiResponse<ApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
public ApiResponse<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
Call call = uploadFileCall(petId, additionalMetadata, file, null, null);
|
||||
Type localVarReturnType = new TypeToken<ApiResponse>(){}.getType();
|
||||
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
|
||||
return apiClient.execute(call, localVarReturnType);
|
||||
}
|
||||
|
||||
@ -885,7 +885,7 @@ public class PetApi {
|
||||
* @return The request call
|
||||
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||
*/
|
||||
public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback<ApiResponse> callback) throws ApiException {
|
||||
public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback<ModelApiResponse> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
@ -907,7 +907,7 @@ public class PetApi {
|
||||
}
|
||||
|
||||
Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener);
|
||||
Type localVarReturnType = new TypeToken<ApiResponse>(){}.getType();
|
||||
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
|
||||
apiClient.executeAsync(call, localVarReturnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:59.477+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00")
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:59.477+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
public class ApiResponse {
|
||||
public class ModelApiResponse {
|
||||
|
||||
@SerializedName("code")
|
||||
private Integer code = null;
|
||||
@ -60,10 +60,10 @@ public class ApiResponse {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ApiResponse apiResponse = (ApiResponse) o;
|
||||
return Objects.equals(this.code, apiResponse.code) &&
|
||||
Objects.equals(this.type, apiResponse.type) &&
|
||||
Objects.equals(this.message, apiResponse.message);
|
||||
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||
return Objects.equals(this.code, _apiResponse.code) &&
|
||||
Objects.equals(this.type, _apiResponse.type) &&
|
||||
Objects.equals(this.message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,7 +74,7 @@ public class ApiResponse {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ApiResponse {\n");
|
||||
sb.append("class ModelApiResponse {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
Loading…
x
Reference in New Issue
Block a user