代码优先还是设计优先?说说API开发技术(四)

举报
Jet Ding 发表于 2021/07/26 09:41:10 2021/07/26
【摘要】 生成更多客户端 userApi.java:/* * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * The version of th...
生成更多客户端 

94.png

userApi.java:

/*

 * OpenAPI Petstore

 * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.

 *

 * The version of the OpenAPI document: 1.0.0

 * 

 *

 * 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.api;

 

import org.openapitools.client.ApiCallback;

import org.openapitools.client.ApiClient;

import org.openapitools.client.ApiException;

import org.openapitools.client.ApiResponse;

import org.openapitools.client.Configuration;

import org.openapitools.client.Pair;

import org.openapitools.client.ProgressRequestBody;

import org.openapitools.client.ProgressResponseBody;

 

import com.google.gson.reflect.TypeToken;

 

import java.io.IOException;

 

import org.openapitools.client.model.User;

 

import java.lang.reflect.Type;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

 

public class UserApi {

    private ApiClient localVarApiClient;

 

    public UserApi() {

        this(Configuration.getDefaultApiClient());

    }

 

    public UserApi(ApiClient apiClient) {

        this.localVarApiClient = apiClient;

    }

 

    public ApiClient getApiClient() {

        return localVarApiClient;

    }

 

    public void setApiClient(ApiClient apiClient) {

        this.localVarApiClient = apiClient;

    }

 

    /**

     * Build call for createUser

     * @param body Created user object (required)

     * @param _callback Callback for upload/download progress

     * @return Call to execute

     * @throws ApiException If fail to serialize the request body object

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throws ApiException {

        Object localVarPostBody = body;

 

        // create path and map variables

        String localVarPath = "/user";

 

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, String> localVarCookieParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {

            

        };

        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);

        if (localVarAccept != null) {

            localVarHeaderParams.put("Accept", localVarAccept);

        }

 

        final String[] localVarContentTypes = {

            

        };

        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);

        localVarHeaderParams.put("Content-Type", localVarContentType);

 

        String[] localVarAuthNames = new String[] {  };

        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);

    }

 

    @SuppressWarnings("rawtypes")

    private okhttp3.Call createUserValidateBeforeCall(User body, final ApiCallback _callback) throws ApiException {

        

        // verify the required parameter 'body' is set

        if (body == null) {

            throw new ApiException("Missing the required parameter 'body' when calling createUser(Async)");

        }

        

 

        okhttp3.Call localVarCall = createUserCall(body, _callback);

        return localVarCall;

 

    }

 

    /**

     * Create user

     * This can only be done by the logged in user.

     * @param body Created user object (required)

     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public void createUser(User body) throws ApiException {

        createUserWithHttpInfo(body);

    }

 

    /**

     * Create user

     * This can only be done by the logged in user.

     * @param body Created user object (required)

     * @return ApiResponse&lt;Void&gt;

     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public ApiResponse<Void> createUserWithHttpInfo(User body) throws ApiException {

        okhttp3.Call localVarCall = createUserValidateBeforeCall(body, null);

        return localVarApiClient.execute(localVarCall);

    }

 

    /**

     * Create user (asynchronously)

     * This can only be done by the logged in user.

     * @param body Created user object (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

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call createUserAsync(User body, final ApiCallback<Void> _callback) throws ApiException {

 

        okhttp3.Call localVarCall = createUserValidateBeforeCall(body, _callback);

        localVarApiClient.executeAsync(localVarCall, _callback);

        return localVarCall;

    }

    /**

     * Build call for createUsersWithArrayInput

     * @param body List of user object (required)

     * @param _callback Callback for upload/download progress

     * @return Call to execute

     * @throws ApiException If fail to serialize the request body object

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call createUsersWithArrayInputCall(List<User> body, final ApiCallback _callback) throws ApiException {

        Object localVarPostBody = body;

 

        // create path and map variables

        String localVarPath = "/user/createWithArray";

 

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, String> localVarCookieParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {

            

        };

        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);

        if (localVarAccept != null) {

            localVarHeaderParams.put("Accept", localVarAccept);

        }

 

        final String[] localVarContentTypes = {

            

        };

        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);

        localVarHeaderParams.put("Content-Type", localVarContentType);

 

        String[] localVarAuthNames = new String[] {  };

        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);

    }

 

    @SuppressWarnings("rawtypes")

    private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List<User> body, final ApiCallback _callback) throws ApiException {

        

        // verify the required parameter 'body' is set

        if (body == null) {

            throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)");

        }

        

 

        okhttp3.Call localVarCall = createUsersWithArrayInputCall(body, _callback);

        return localVarCall;

 

    }

 

    /**

     * Creates list of users with given input array

     * 

     * @param body List of user object (required)

     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public void createUsersWithArrayInput(List<User> body) throws ApiException {

        createUsersWithArrayInputWithHttpInfo(body);

    }

 

    /**

     * Creates list of users with given input array

     * 

     * @param body List of user object (required)

     * @return ApiResponse&lt;Void&gt;

     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public ApiResponse<Void> createUsersWithArrayInputWithHttpInfo(List<User> body) throws ApiException {

        okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null);

        return localVarApiClient.execute(localVarCall);

    }

 

    /**

     * Creates list of users with given input array (asynchronously)

     * 

     * @param body List of user object (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

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call createUsersWithArrayInputAsync(List<User> body, final ApiCallback<Void> _callback) throws ApiException {

 

        okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _callback);

        localVarApiClient.executeAsync(localVarCall, _callback);

        return localVarCall;

    }

    /**

     * Build call for createUsersWithListInput

     * @param body List of user object (required)

     * @param _callback Callback for upload/download progress

     * @return Call to execute

     * @throws ApiException If fail to serialize the request body object

     * @http.response.details

     <table summary="Response Details" border="1">

        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>

        <tr><td> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call createUsersWithListInputCall(List<User> body, final ApiCallback _callback) throws ApiException {

        Object localVarPostBody = body;

 

        // create path and map variables

        String localVarPath = "/user/createWithList";

 

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, String> localVarCookieParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {

            

        };

        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);

        if (localVarAccept != null) {

            localVarHeaderParams.put("Accept", localVarAccept);

        }

 

        final String[] localVarContentTypes = {

            

        };

        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);

        localVarHeaderParams.put("Content-Type", localVarContentType);

 

        String[] localVarAuthNames = new String[] {  };

        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);

    }

 

    @SuppressWarnings("rawtypes")

    private okhttp3.Call createUsersWithListInputValidateBeforeCall(List<User> body, final ApiCallback _callback) throws ApiException {

        

        // verify the required parameter 'body' is set

        if (body == null) {

            throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)");

        }

        

 

        okhttp3.Call localVarCall = createUsersWithListInputCall(body, _callback);

        return localVarCall;

 

    }

 
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200