mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
update sample & test
This commit is contained in:
parent
dc65b5647f
commit
98396d04a7
@ -853,7 +853,7 @@ public class ApiClient {
|
||||
|
||||
Request request = null;
|
||||
|
||||
if(progressRequestListener != null) {
|
||||
if(progressRequestListener != null && reqBody != null) {
|
||||
ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener);
|
||||
request = reqBuilder.method(method, progressRequestBody).build();
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ public class {{classname}} {
|
||||
|
||||
{{#operation}}
|
||||
/* Build call for {{nickname}} */
|
||||
private Call {{nickname}}Call({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call {{nickname}}Call({{#allParams}}{{{dataType}}} {{paramName}},{{/allParams}} final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
@ -106,7 +106,7 @@ public class {{classname}} {
|
||||
* @return {{{returnType}}}{{/returnType}}
|
||||
*/
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Call {{localVariablePrefix}}call = {{nickname}}Call({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}, null, null);
|
||||
Call {{localVariablePrefix}}call = {{nickname}}Call({{#allParams}}{{paramName}},{{/allParams}} null, null);
|
||||
{{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||
return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}returnType);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}}
|
||||
}
|
||||
@ -139,7 +139,7 @@ public class {{classname}} {
|
||||
};
|
||||
}
|
||||
|
||||
Call {{localVariablePrefix}}call = {{nickname}}Call({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}, progressListener, progressRequestListener);
|
||||
Call {{localVariablePrefix}}call = {{nickname}}Call({{#allParams}}{{paramName}},{{/allParams}} progressListener, progressRequestListener);
|
||||
{{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||
{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}returnType, {{localVariablePrefix}}callback);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}callback);{{/returnType}}
|
||||
return {{localVariablePrefix}}call;
|
||||
|
@ -852,7 +852,7 @@ public class ApiClient {
|
||||
|
||||
Request request = null;
|
||||
|
||||
if(progressRequestListener != null) {
|
||||
if(progressRequestListener != null && reqBody != null) {
|
||||
ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener);
|
||||
request = reqBuilder.method(method, progressRequestBody).build();
|
||||
} else {
|
||||
|
@ -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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -487,7 +487,7 @@ public class PetApi {
|
||||
}
|
||||
|
||||
/* Build call for updatePetWithForm */
|
||||
private Call updatePetWithFormCall(String petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call updatePetWithFormCall(String petId,String name,String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -546,7 +546,7 @@ public class PetApi {
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
public void updatePetWithForm(String petId, String name, String status) throws ApiException {
|
||||
Call call = updatePetWithFormCall(petId, name, status, null, null);
|
||||
Call call = updatePetWithFormCall(petId,name,status, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -580,13 +580,13 @@ public class PetApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = updatePetWithFormCall(petId, name, status, progressListener, progressRequestListener);
|
||||
Call call = updatePetWithFormCall(petId,name,status, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for deletePet */
|
||||
private Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call deletePetCall(Long petId,String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -642,7 +642,7 @@ public class PetApi {
|
||||
* @param apiKey
|
||||
*/
|
||||
public void deletePet(Long petId, String apiKey) throws ApiException {
|
||||
Call call = deletePetCall(petId, apiKey, null, null);
|
||||
Call call = deletePetCall(petId,apiKey, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -675,13 +675,13 @@ public class PetApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = deletePetCall(petId, apiKey, progressListener, progressRequestListener);
|
||||
Call call = deletePetCall(petId,apiKey, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for uploadFile */
|
||||
private Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call uploadFileCall(Long petId,String additionalMetadata,File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -740,7 +740,7 @@ public class PetApi {
|
||||
* @param file file to upload
|
||||
*/
|
||||
public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
Call call = uploadFileCall(petId, additionalMetadata, file, null, null);
|
||||
Call call = uploadFileCall(petId,additionalMetadata,file, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -774,7 +774,7 @@ public class PetApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener);
|
||||
Call call = uploadFileCall(petId,additionalMetadata,file, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class StoreApi {
|
||||
|
||||
|
||||
/* Build call for getInventory */
|
||||
private Call getInventoryCall(, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call getInventoryCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ public class StoreApi {
|
||||
* @return Map<String, Integer>
|
||||
*/
|
||||
public Map<String, Integer> getInventory() throws ApiException {
|
||||
Call call = getInventoryCall(, null, null);
|
||||
Call call = getInventoryCall( null, null);
|
||||
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -122,7 +122,7 @@ public class StoreApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = getInventoryCall(, progressListener, progressRequestListener);
|
||||
Call call = getInventoryCall( progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
|
@ -298,7 +298,7 @@ public class UserApi {
|
||||
}
|
||||
|
||||
/* Build call for loginUser */
|
||||
private Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call loginUserCall(String username,String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -351,7 +351,7 @@ public class UserApi {
|
||||
* @return String
|
||||
*/
|
||||
public String loginUser(String username, String password) throws ApiException {
|
||||
Call call = loginUserCall(username, password, null, null);
|
||||
Call call = loginUserCall(username,password, null, null);
|
||||
Type returnType = new TypeToken<String>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -385,14 +385,14 @@ public class UserApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = loginUserCall(username, password, progressListener, progressRequestListener);
|
||||
Call call = loginUserCall(username,password, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<String>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for logoutUser */
|
||||
private Call logoutUserCall(, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call logoutUserCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -438,7 +438,7 @@ public class UserApi {
|
||||
*
|
||||
*/
|
||||
public void logoutUser() throws ApiException {
|
||||
Call call = logoutUserCall(, null, null);
|
||||
Call call = logoutUserCall( null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -469,7 +469,7 @@ public class UserApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = logoutUserCall(, progressListener, progressRequestListener);
|
||||
Call call = logoutUserCall( progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
@ -569,7 +569,7 @@ public class UserApi {
|
||||
}
|
||||
|
||||
/* Build call for updateUser */
|
||||
private Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
private Call updateUserCall(String username,User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -623,7 +623,7 @@ public class UserApi {
|
||||
* @param body Updated user object
|
||||
*/
|
||||
public void updateUser(String username, User body) throws ApiException {
|
||||
Call call = updateUserCall(username, body, null, null);
|
||||
Call call = updateUserCall(username,body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -656,7 +656,7 @@ public class UserApi {
|
||||
};
|
||||
}
|
||||
|
||||
Call call = updateUserCall(username, body, progressListener, progressRequestListener);
|
||||
Call call = updateUserCall(username,body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, 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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+08:00")
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -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 = "2015-11-21T19:41:14.431+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-21T20:11:09.490+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
@ -88,6 +88,16 @@ public class PetApiTest {
|
||||
public void onSuccess(Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
});
|
||||
// the API call should be executed asynchronously, so result should be empty at the moment
|
||||
assertTrue(result.isEmpty());
|
||||
@ -123,6 +133,16 @@ public class PetApiTest {
|
||||
public void onSuccess(Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
});
|
||||
// the API call should be executed asynchronously, so result should be empty at the moment
|
||||
assertTrue(result.isEmpty());
|
||||
|
Loading…
Reference in New Issue
Block a user