org.openapitools.client.ApiException Java Examples

The following examples show how to use org.openapitools.client.ApiException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private okhttp3.Call updateUserValidateBeforeCall(String username, User body, final ApiCallback _callback) throws ApiException {
    
    // verify the required parameter 'username' is set
    if (username == null) {
        throw new ApiException("Missing the required parameter 'username' when calling updateUser(Async)");
    }
    
    // verify the required parameter 'body' is set
    if (body == null) {
        throw new ApiException("Missing the required parameter 'body' when calling updateUser(Async)");
    }
    

    okhttp3.Call localVarCall = updateUserCall(username, body, _callback);
    return localVarCall;

}
 
Example #2
Source File: ApiKeyAuth.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
  if (apiKey == null) {
    return;
  }
  String value;
  if (apiKeyPrefix != null) {
    value = apiKeyPrefix + " " + apiKey;
  } else {
    value = apiKey;
  }
  if ("query".equals(location)) {
    queryParams.add(new Pair(paramName, value));
  } else if ("header".equals(location)) {
    headerParams.put(paramName, value);
  } else if ("cookie".equals(location)) {
    cookieParams.put(paramName, value);
  }
}
 
Example #3
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(Boolean body) throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/fake/outer/boolean";

    localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

    localVarRequestBuilder.header("Content-Type", "application/json");
    localVarRequestBuilder.header("Accept", "application/json");

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body);
      localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
    } catch (IOException e) {
      throw new ApiException(e);
    }
    if (memberVarReadTimeout != null) {
      localVarRequestBuilder.timeout(memberVarReadTimeout);
    }
    if (memberVarInterceptor != null) {
      memberVarInterceptor.accept(localVarRequestBuilder);
    }
    return localVarRequestBuilder;
  }
 
Example #4
Source File: UserApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
private HttpRequest.Builder getUserByNameRequestBuilder(String username) throws ApiException {
  // verify the required parameter 'username' is set
  if (username == null) {
    throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/user/{username}"
      .replace("{username}", ApiClient.urlEncode(username.toString()));

  localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

  localVarRequestBuilder.header("Accept", "application/json");

  localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}
 
Example #5
Source File: StoreApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/store/inventory";

    localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

    localVarRequestBuilder.header("Accept", "application/json");

    localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
    if (memberVarReadTimeout != null) {
      localVarRequestBuilder.timeout(memberVarReadTimeout);
    }
    if (memberVarInterceptor != null) {
      memberVarInterceptor.accept(localVarRequestBuilder);
    }
    return localVarRequestBuilder;
  }
 
Example #6
Source File: StoreApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build call for deleteOrder
 * @param orderId ID of the order that needs to be deleted (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> 400 </td><td> Invalid ID supplied </td><td>  -  </td></tr>
    <tr><td> 404 </td><td> Order not found </td><td>  -  </td></tr>
 </table>
 */
public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) throws ApiException {
    Object localVarPostBody = null;

    // create path and map variables
    String localVarPath = "/store/order/{order_id}"
        .replaceAll("\\{" + "order_id" + "\\}", localVarApiClient.escapeString(orderId.toString()));

    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, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
 
Example #7
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build call for testBodyWithFileSchema
 * @param body  (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> 200 </td><td> Success </td><td>  -  </td></tr>
 </table>
 */
public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException {
    Object localVarPostBody = body;

    // create path and map variables
    String localVarPath = "/fake/body-with-file-schema";

    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 = {
        "application/json"
    };
    final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    String[] localVarAuthNames = new String[] {  };
    return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
 
Example #8
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build call for fakeOuterStringSerialize
 * @param body Input string as post body (optional)
 * @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> 200 </td><td> Output string </td><td>  -  </td></tr>
 </table>
 */
public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback _callback) throws ApiException {
    Object localVarPostBody = body;

    // create path and map variables
    String localVarPath = "/fake/outer/string";

    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);
}
 
Example #9
Source File: PetApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Find pet by ID
 * Returns a single pet
 * @param petId ID of pet to return (required)
 * @return a {@code Pet}
 * @throws ApiException if fails to make API call
 */
public Pet getPetById(Long petId) throws ApiException {
  Object localVarPostBody = null;
  
  // verify the required parameter 'petId' is set
  if (petId == null) {
    throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById");
  }
  
  // create path and map variables
  String localVarPath = "/pet/{petId}".replaceAll("\\{format\\}","json")
    .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));

  // query params
  List<Pair> localVarQueryParams = 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 = {
    "application/xml", "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

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

  GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
  return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
    }
 
Example #10
Source File: PetApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * uploads an image (required)
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void uploadFileWithRequiredFileTest() throws ApiException {
    Long petId = null;
    File requiredFile = null;
    String additionalMetadata = null;
    //ModelApiResponse response = api.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata);
    // TODO: test validations
}
 
Example #11
Source File: PetApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build call for findPetsByStatus
 * @param status Status values that need to be considered for filter (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> 200 </td><td> successful operation </td><td>  -  </td></tr>
    <tr><td> 400 </td><td> Invalid status value </td><td>  -  </td></tr>
 </table>
 */
public okhttp3.Call findPetsByStatusCall(List<String> status, final ApiCallback _callback) throws ApiException {
    Object localVarPostBody = null;

    // create path and map variables
    String localVarPath = "/pet/findByStatus";

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
    if (status != null) {
        localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "status", status));
    }

    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 = {
        "application/xml", "application/json"
    };
    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[] { "petstore_auth" };
    return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
 
Example #12
Source File: StoreApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build call for placeOrder
 * @param body order placed for purchasing the pet (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> 200 </td><td> successful operation </td><td>  -  </td></tr>
    <tr><td> 400 </td><td> Invalid Order </td><td>  -  </td></tr>
 </table>
 */
public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) throws ApiException {
    Object localVarPostBody = body;

    // create path and map variables
    String localVarPath = "/store/order";

    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 = {
        "application/xml", "application/json"
    };
    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);
}
 
Example #13
Source File: UserApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Updated user
 *
 * This can only be done by the logged in user.
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void updateUserTest() throws ApiException {
    String username = null;
    User body = null;
    api.updateUser(username, body);

    // TODO: test validations
}
 
Example #14
Source File: PetApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build call for deletePet
 * @param petId Pet id to delete (required)
 * @param apiKey  (optional)
 * @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> 200 </td><td> successful operation </td><td>  -  </td></tr>
    <tr><td> 400 </td><td> Invalid pet value </td><td>  -  </td></tr>
 </table>
 */
public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException {
    Object localVarPostBody = null;

    // create path and map variables
    String localVarPath = "/pet/{petId}"
        .replaceAll("\\{" + "petId" + "\\}", localVarApiClient.escapeString(petId.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    if (apiKey != null) {
        localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
    }

    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[] { "petstore_auth" };
    return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
 
Example #15
Source File: UserApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Logs user into the system
 *
 * 
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void loginUserTest() throws ApiException {
    String username = null;
    String password = null;
    String response = api.loginUser(username, password);

    // TODO: test validations
}
 
Example #16
Source File: PetApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(Long petId, File requiredFile, String additionalMetadata) throws ApiException {
  // verify the required parameter 'petId' is set
  if (petId == null) {
    throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile");
  }
  // verify the required parameter 'requiredFile' is set
  if (requiredFile == null) {
    throw new ApiException(400, "Missing the required parameter 'requiredFile' when calling uploadFileWithRequiredFile");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/fake/{petId}/uploadImageWithRequiredFile"
      .replace("{petId}", ApiClient.urlEncode(petId.toString()));

  localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

  localVarRequestBuilder.header("Accept", "application/json");

  localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}
 
Example #17
Source File: FakeApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Fake endpoint to test group parameters (optional)
 *
 * Fake endpoint to test group parameters (optional)
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void testGroupParametersTest() throws ApiException {
    Integer requiredStringGroup = null;
    Boolean requiredBooleanGroup = null;
    Long requiredInt64Group = null;
    Integer stringGroup = null;
    Boolean booleanGroup = null;
    Long int64Group = null;
    api.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group);

    // TODO: test validations
}
 
Example #18
Source File: FakeClassnameTags123Api.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * To test class name in snake case
 * To test class name in snake case
 * @param body client model (required)
 * @return a {@code Client}
 * @throws ApiException if fails to make API call
 */
public Client testClassname(Client body) throws ApiException {
  Object localVarPostBody = body;
  
  // verify the required parameter 'body' is set
  if (body == null) {
    throw new ApiException(400, "Missing the required parameter 'body' when calling testClassname");
  }
  
  // create path and map variables
  String localVarPath = "/fake_classname_test".replaceAll("\\{format\\}","json");

  // query params
  List<Pair> localVarQueryParams = 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 = {
    "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    "application/json"
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

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

  GenericType<Client> localVarReturnType = new GenericType<Client>() {};
  return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
    }
 
Example #19
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(Map<String, String> param) throws ApiException {
  // verify the required parameter 'param' is set
  if (param == null) {
    throw new ApiException(400, "Missing the required parameter 'param' when calling testInlineAdditionalProperties");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/fake/inline-additionalProperties";

  localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

  localVarRequestBuilder.header("Content-Type", "application/json");
  localVarRequestBuilder.header("Accept", "application/json");

  try {
    byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(param);
    localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
  } catch (IOException e) {
    throw new ApiException(e);
  }
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}
 
Example #20
Source File: UserApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Logs user into the system
 *
 * 
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void loginUserTest() throws ApiException {
    String username = null;
    String password = null;
    String response = api.loginUser(username, password);

    // TODO: test validations
}
 
Example #21
Source File: UserApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates list of users with given input array
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void createUsersWithListInputTest() throws ApiException {
    //
    //List<User> body = null;
    //
    //api.createUsersWithListInput(body);

    // TODO: test validations
}
 
Example #22
Source File: PetApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
private HttpRequest.Builder findPetsByTagsRequestBuilder(Set<String> tags) throws ApiException {
  // verify the required parameter 'tags' is set
  if (tags == null) {
    throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/pet/findByTags";

  List<Pair> localVarQueryParams = new ArrayList<>();
  localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags));

  if (!localVarQueryParams.isEmpty()) {
    StringJoiner queryJoiner = new StringJoiner("&");
    localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
    localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
  } else {
    localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
  }

  localVarRequestBuilder.header("Accept", "application/json");

  localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}
 
Example #23
Source File: FakeApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * To test enum parameters
 *
 * To test enum parameters
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void testEnumParametersTest() throws ApiException {
    List<String> enumHeaderStringArray = null;
    String enumHeaderString = null;
    List<String> enumQueryStringArray = null;
    String enumQueryString = null;
    Integer enumQueryInteger = null;
    Double enumQueryDouble = null;
    List<String> enumFormStringArray = null;
    String enumFormString = null;
    api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);

    // TODO: test validations
}
 
Example #24
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
private HttpRequest.Builder testEndpointParametersRequestBuilder(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, File binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException {
  // verify the required parameter 'number' is set
  if (number == null) {
    throw new ApiException(400, "Missing the required parameter 'number' when calling testEndpointParameters");
  }
  // verify the required parameter '_double' is set
  if (_double == null) {
    throw new ApiException(400, "Missing the required parameter '_double' when calling testEndpointParameters");
  }
  // verify the required parameter 'patternWithoutDelimiter' is set
  if (patternWithoutDelimiter == null) {
    throw new ApiException(400, "Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters");
  }
  // verify the required parameter '_byte' is set
  if (_byte == null) {
    throw new ApiException(400, "Missing the required parameter '_byte' when calling testEndpointParameters");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/fake";

  localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

  localVarRequestBuilder.header("Accept", "application/json");

  localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}
 
Example #25
Source File: FakeApiTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * To test enum parameters
 *
 * To test enum parameters
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void testEnumParametersTest() throws ApiException {
    List<String> enumHeaderStringArray = null;
    String enumHeaderString = null;
    List<String> enumQueryStringArray = null;
    String enumQueryString = null;
    Integer enumQueryInteger = null;
    Double enumQueryDouble = null;
    List<String> enumFormStringArray = null;
    String enumFormString = null;
    api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);

    // TODO: test validations
}
 
Example #26
Source File: UserApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
private HttpRequest.Builder createUsersWithListInputRequestBuilder(List<User> body) throws ApiException {
  // verify the required parameter 'body' is set
  if (body == null) {
    throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/user/createWithList";

  localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

  localVarRequestBuilder.header("Content-Type", "application/json");
  localVarRequestBuilder.header("Accept", "application/json");

  try {
    byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body);
    localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
  } catch (IOException e) {
    throw new ApiException(e);
  }
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}
 
Example #27
Source File: PetApi.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
/**
 * Finds Pets by tags
 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
 * @param tags Tags to filter by (required)
 * @return ApiResponse&lt;Set&lt;Pet&gt;&gt;
 * @throws ApiException if fails to make API call
 * @http.response.details
   <table summary="Response Details" border="1">
     <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
     <tr><td> 200 </td><td> successful operation </td><td>  -  </td></tr>
     <tr><td> 400 </td><td> Invalid tag value </td><td>  -  </td></tr>
   </table>
 * @deprecated
 */
@Deprecated
public ApiResponse<Set<Pet>> findPetsByTagsWithHttpInfo(Set<String> tags) throws ApiException {
  Object localVarPostBody = null;
  
  // verify the required parameter 'tags' is set
  if (tags == null) {
    throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags");
  }
  
  // create path and map variables
  String localVarPath = "/pet/findByTags";

  // query params
  List<Pair> localVarQueryParams = 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>();

  localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags));

  
  
  
  final String[] localVarAccepts = {
    "application/xml", "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

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

  GenericType<Set<Pet>> localVarReturnType = new GenericType<Set<Pet>>() {};

  return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody,
                             localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
                             localVarAuthNames, localVarReturnType, false);
}
 
Example #28
Source File: StoreApi.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
/**
 * Returns pet inventories by status
 * Returns a map of status codes to quantities

*/
public void getInventory (final Response.Listener<Map<String, Integer>> responseListener, final Response.ErrorListener errorListener) {
  Object postBody = null;


  // create path and map variables
  String path = "/store/inventory".replaceAll("\\{format\\}","json");

  // query params
  List<Pair> queryParams = new ArrayList<Pair>();
  // header params
  Map<String, String> headerParams = new HashMap<String, String>();
  // form params
  Map<String, String> formParams = new HashMap<String, String>();



  String[] contentTypes = {
    
  };
  String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";

  if (contentType.startsWith("multipart/form-data")) {
    // file uploading
    MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
    

    HttpEntity httpEntity = localVarBuilder.build();
    postBody = httpEntity;
  } else {
    // normal form params
        }

  String[] authNames = new String[] { "api_key" };

  try {
    apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
      new Response.Listener<String>() {
        @Override
        public void onResponse(String localVarResponse) {
          try {
            responseListener.onResponse((Map<String, Integer>) ApiInvoker.deserialize(localVarResponse,  "map", Integer.class));
          } catch (ApiException exception) {
             errorListener.onErrorResponse(new VolleyError(exception));
          }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
          errorListener.onErrorResponse(error);
        }
    });
  } catch (ApiException ex) {
    errorListener.onErrorResponse(new VolleyError(ex));
  }
}
 
Example #29
Source File: UserApi.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
/**
 * Logs user into the system
 * 
 * @param username The user name for login (required)
 * @param password The password for login in clear text (required)
 * @return ApiResponse&lt;String&gt;
 * @throws ApiException if fails to make API call
 * @http.response.details
   <table summary="Response Details" border="1">
     <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
     <tr><td> 200 </td><td> successful operation </td><td>  * X-Rate-Limit - calls per hour allowed by the user <br>  * X-Expires-After - date in UTC when token expires <br>  </td></tr>
     <tr><td> 400 </td><td> Invalid username/password supplied </td><td>  -  </td></tr>
   </table>
 */
public ApiResponse<String> loginUserWithHttpInfo(String username, String password) throws ApiException {
  Object localVarPostBody = null;
  
  // verify the required parameter 'username' is set
  if (username == null) {
    throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser");
  }
  
  // verify the required parameter 'password' is set
  if (password == null) {
    throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser");
  }
  
  // create path and map variables
  String localVarPath = "/user/login";

  // query params
  List<Pair> localVarQueryParams = 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>();

  localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username));
  localVarQueryParams.addAll(apiClient.parameterToPairs("", "password", password));

  
  
  
  final String[] localVarAccepts = {
    "application/xml", "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

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

  GenericType<String> localVarReturnType = new GenericType<String>() {};

  return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody,
                             localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
                             localVarAuthNames, localVarReturnType, false);
}
 
Example #30
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context) throws ApiException {
  // verify the required parameter 'pipe' is set
  if (pipe == null) {
    throw new ApiException(400, "Missing the required parameter 'pipe' when calling testQueryParameterCollectionFormat");
  }
  // verify the required parameter 'ioutil' is set
  if (ioutil == null) {
    throw new ApiException(400, "Missing the required parameter 'ioutil' when calling testQueryParameterCollectionFormat");
  }
  // verify the required parameter 'http' is set
  if (http == null) {
    throw new ApiException(400, "Missing the required parameter 'http' when calling testQueryParameterCollectionFormat");
  }
  // verify the required parameter 'url' is set
  if (url == null) {
    throw new ApiException(400, "Missing the required parameter 'url' when calling testQueryParameterCollectionFormat");
  }
  // verify the required parameter 'context' is set
  if (context == null) {
    throw new ApiException(400, "Missing the required parameter 'context' when calling testQueryParameterCollectionFormat");
  }

  HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

  String localVarPath = "/fake/test-query-paramters";

  List<Pair> localVarQueryParams = new ArrayList<>();
  localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "pipe", pipe));
  localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "ioutil", ioutil));
  localVarQueryParams.addAll(ApiClient.parameterToPairs("ssv", "http", http));
  localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "url", url));
  localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "context", context));

  if (!localVarQueryParams.isEmpty()) {
    StringJoiner queryJoiner = new StringJoiner("&");
    localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
    localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
  } else {
    localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
  }

  localVarRequestBuilder.header("Accept", "application/json");

  localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.noBody());
  if (memberVarReadTimeout != null) {
    localVarRequestBuilder.timeout(memberVarReadTimeout);
  }
  if (memberVarInterceptor != null) {
    memberVarInterceptor.accept(localVarRequestBuilder);
  }
  return localVarRequestBuilder;
}