forked from loafle/openapi-generator-original
Update samples for okhttp-gson.
This commit is contained in:
parent
2133861e1f
commit
8ce4563afc
@ -0,0 +1,52 @@
|
|||||||
|
# FakeClassnameTags123Api
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||||
|
|
||||||
|
|
||||||
|
<a name="testClassname"></a>
|
||||||
|
# **testClassname**
|
||||||
|
> Client testClassname(body)
|
||||||
|
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
//import io.swagger.client.ApiException;
|
||||||
|
//import io.swagger.client.api.FakeClassnameTags123Api;
|
||||||
|
|
||||||
|
|
||||||
|
FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api();
|
||||||
|
Client body = new Client(); // Client | client model
|
||||||
|
try {
|
||||||
|
Client result = apiInstance.testClassname(body);
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling FakeClassnameTags123Api#testClassname");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**Client**](Client.md)| client model |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Client**](Client.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
* Contact: apiteam@swagger.io
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiCallback;
|
||||||
|
import io.swagger.client.ApiClient;
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.ApiResponse;
|
||||||
|
import io.swagger.client.Configuration;
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
import io.swagger.client.ProgressRequestBody;
|
||||||
|
import io.swagger.client.ProgressResponseBody;
|
||||||
|
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.client.model.Client;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FakeClassnameTags123Api {
|
||||||
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
public FakeClassnameTags123Api() {
|
||||||
|
this(Configuration.getDefaultApiClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeClassnameTags123Api(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient getApiClient() {
|
||||||
|
return apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiClient(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build call for testClassname */
|
||||||
|
private com.squareup.okhttp.Call testClassnameCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||||
|
Object localVarPostBody = body;
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String localVarPath = "/fake_classname_test".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
final String[] localVarAccepts = {
|
||||||
|
"application/json"
|
||||||
|
};
|
||||||
|
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||||
|
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
|
||||||
|
|
||||||
|
final String[] localVarContentTypes = {
|
||||||
|
"application/json"
|
||||||
|
};
|
||||||
|
final String localVarContentType = apiClient.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, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private com.squareup.okhttp.Call testClassnameValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||||
|
|
||||||
|
// verify the required parameter 'body' is set
|
||||||
|
if (body == null) {
|
||||||
|
throw new ApiException("Missing the required parameter 'body' when calling testClassname(Async)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
com.squareup.okhttp.Call call = testClassnameCall(body, progressListener, progressRequestListener);
|
||||||
|
return call;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test class name in snake case
|
||||||
|
*
|
||||||
|
* @param body client model (required)
|
||||||
|
* @return Client
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
*/
|
||||||
|
public Client testClassname(Client body) throws ApiException {
|
||||||
|
ApiResponse<Client> resp = testClassnameWithHttpInfo(body);
|
||||||
|
return resp.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test class name in snake case
|
||||||
|
*
|
||||||
|
* @param body client model (required)
|
||||||
|
* @return ApiResponse<Client>
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
*/
|
||||||
|
public ApiResponse<Client> testClassnameWithHttpInfo(Client body) throws ApiException {
|
||||||
|
com.squareup.okhttp.Call call = testClassnameValidateBeforeCall(body, null, null);
|
||||||
|
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||||
|
return apiClient.execute(call, localVarReturnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test class name in snake case (asynchronously)
|
||||||
|
*
|
||||||
|
* @param body client model (required)
|
||||||
|
* @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 testClassnameAsync(Client body, final ApiCallback<Client> 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 = testClassnameValidateBeforeCall(body, progressListener, progressRequestListener);
|
||||||
|
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||||
|
apiClient.executeAsync(call, localVarReturnType, callback);
|
||||||
|
return call;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
* Contact: apiteam@swagger.io
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.model.Client;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API tests for FakeClassnameTags123Api
|
||||||
|
*/
|
||||||
|
@Ignore
|
||||||
|
public class FakeClassnameTags123ApiTest {
|
||||||
|
|
||||||
|
private final FakeClassnameTags123Api api = new FakeClassnameTags123Api();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test class name in snake case
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException
|
||||||
|
* if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testClassnameTest() throws ApiException {
|
||||||
|
Client body = null;
|
||||||
|
Client response = api.testClassname(body);
|
||||||
|
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user