Don't generate unused ApiException class for java/webclient. (#1165)

This commit is contained in:
moreginger 2018-10-21 15:01:47 +01:00 committed by William Cheng
parent f1d4ae230e
commit 33a1ac4397
18 changed files with 56 additions and 346 deletions

View File

@ -269,10 +269,13 @@ public class JavaClientCodegen extends AbstractJavaCodegen
apiDocTemplateFiles.remove("api_doc.mustache");
}
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || WEBCLIENT.equals(getLibrary()))) {
supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java"));
supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java"));
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
}
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()))) {
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
}

View File

@ -5,8 +5,7 @@ import {{invokerPackage}}.ApiClient;
{{#imports}}import {{import}};
{{/imports}}
{{^fullJavaUtil}}import java.util.ArrayList;
import java.util.HashMap;
{{^fullJavaUtil}}import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;{{/fullJavaUtil}}

View File

@ -2,7 +2,6 @@
package {{package}};
import {{invokerPackage}}.ApiException;
{{#imports}}import {{import}};
{{/imports}}
import org.junit.Test;
@ -28,12 +27,9 @@ public class {{classname}}Test {
* {{summary}}
*
* {{notes}}
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void {{operationId}}Test() throws ApiException {
public void {{operationId}}Test() {
{{#allParams}}
{{{dataType}}} {{paramName}} = null;
{{/allParams}}

View File

@ -1,91 +0,0 @@
/*
* OpenAPI 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
*
*
* 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;
import java.util.Map;
import java.util.List;
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
private String responseBody = null;
public ApiException() {}
public ApiException(Throwable throwable) {
super(throwable);
}
public ApiException(String message) {
super(message);
}
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
super(message, throwable);
this.code = code;
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
}
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
this(message, (Throwable) null, code, responseHeaders, responseBody);
}
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
this(message, throwable, code, responseHeaders, null);
}
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
this((String) null, (Throwable) null, code, responseHeaders, responseBody);
}
public ApiException(int code, String message) {
super(message);
this.code = code;
}
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
this(code, message);
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
}
/**
* Get the HTTP status code.
*
* @return HTTP status code
*/
public int getCode() {
return code;
}
/**
* Get the HTTP response headers.
*
* @return A map of list of string
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}
/**
* Get the HTTP response body.
*
* @return Response body in the form of string
*/
public String getResponseBody() {
return responseBody;
}
}

View File

@ -1,39 +0,0 @@
/*
* OpenAPI 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
*
*
* 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;
public class Configuration {
private static ApiClient defaultApiClient = new ApiClient();
/**
* Get the default API client, which would be used when creating API
* instances without providing an API client.
*
* @return Default API client
*/
public static ApiClient getDefaultApiClient() {
return defaultApiClient;
}
/**
* Set the default API client, which would be used when creating API
* instances without providing an API client.
*
* @param apiClient API client
*/
public static void setDefaultApiClient(ApiClient apiClient) {
defaultApiClient = apiClient;
}
}

View File

@ -1,61 +0,0 @@
/*
* OpenAPI 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
*
*
* 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;
public class Pair {
private String name = "";
private String value = "";
public Pair (String name, String value) {
setName(name);
setValue(value);
}
private void setName(String name) {
if (!isValidString(name)) {
return;
}
this.name = name;
}
private void setValue(String value) {
if (!isValidString(value)) {
return;
}
this.value = value;
}
public String getName() {
return this.name;
}
public String getValue() {
return this.value;
}
private boolean isValidString(String arg) {
if (arg == null) {
return false;
}
if (arg.trim().isEmpty()) {
return false;
}
return true;
}
}

View File

@ -4,7 +4,6 @@ import org.openapitools.client.ApiClient;
import org.openapitools.client.model.Client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

View File

@ -11,7 +11,6 @@ import java.time.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
import org.openapitools.client.model.User;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

View File

@ -4,7 +4,6 @@ import org.openapitools.client.ApiClient;
import org.openapitools.client.model.Client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

View File

@ -6,7 +6,6 @@ import java.io.File;
import org.openapitools.client.model.ModelApiResponse;
import org.openapitools.client.model.Pet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

View File

@ -4,7 +4,6 @@ import org.openapitools.client.ApiClient;
import org.openapitools.client.model.Order;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

View File

@ -4,7 +4,6 @@ import org.openapitools.client.ApiClient;
import org.openapitools.client.model.User;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

View File

@ -13,7 +13,6 @@
package org.openapitools.client.api;
import org.openapitools.client.ApiException;
import org.openapitools.client.model.Client;
import org.junit.Test;
import org.junit.Ignore;
@ -36,12 +35,9 @@ public class AnotherFakeApiTest {
* To test special tags
*
* To test special tags and operation ID starting with number
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void call123testSpecialTagsTest() throws ApiException {
public void call123testSpecialTagsTest() {
Client client = null;
Client response = api.call123testSpecialTags(client).block();

View File

@ -13,10 +13,10 @@
package org.openapitools.client.api;
import org.openapitools.client.ApiException;
import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
@ -42,12 +42,9 @@ public class FakeApiTest {
*
*
* Test serialization of outer boolean types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterBooleanSerializeTest() throws ApiException {
public void fakeOuterBooleanSerializeTest() {
Boolean body = null;
Boolean response = api.fakeOuterBooleanSerialize(body).block();
@ -58,12 +55,9 @@ public class FakeApiTest {
*
*
* Test serialization of object with outer number type
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterCompositeSerializeTest() throws ApiException {
public void fakeOuterCompositeSerializeTest() {
OuterComposite outerComposite = null;
OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite).block();
@ -74,12 +68,9 @@ public class FakeApiTest {
*
*
* Test serialization of outer number types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterNumberSerializeTest() throws ApiException {
public void fakeOuterNumberSerializeTest() {
BigDecimal body = null;
BigDecimal response = api.fakeOuterNumberSerialize(body).block();
@ -90,12 +81,9 @@ public class FakeApiTest {
*
*
* Test serialization of outer string types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterStringSerializeTest() throws ApiException {
public void fakeOuterStringSerializeTest() {
String body = null;
String response = api.fakeOuterStringSerialize(body).block();
@ -105,13 +93,23 @@ public class FakeApiTest {
/**
*
*
*
*
* @throws ApiException
* if the Api call fails
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.
*/
@Test
public void testBodyWithQueryParamsTest() throws ApiException {
public void testBodyWithFileSchemaTest() {
FileSchemaTestClass fileSchemaTestClass = null;
api.testBodyWithFileSchema(fileSchemaTestClass).block();
// TODO: test validations
}
/**
*
*
*
*/
@Test
public void testBodyWithQueryParamsTest() {
String query = null;
User user = null;
api.testBodyWithQueryParams(query, user).block();
@ -123,12 +121,9 @@ public class FakeApiTest {
* To test \&quot;client\&quot; model
*
* To test \&quot;client\&quot; model
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testClientModelTest() throws ApiException {
public void testClientModelTest() {
Client client = null;
Client response = api.testClientModel(client).block();
@ -139,12 +134,9 @@ public class FakeApiTest {
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testEndpointParametersTest() throws ApiException {
public void testEndpointParametersTest() {
BigDecimal number = null;
Double _double = null;
String patternWithoutDelimiter = null;
@ -168,12 +160,9 @@ public class FakeApiTest {
* To test enum parameters
*
* To test enum parameters
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testEnumParametersTest() throws ApiException {
public void testEnumParametersTest() {
List<String> enumHeaderStringArray = null;
String enumHeaderString = null;
List<String> enumQueryStringArray = null;
@ -191,12 +180,9 @@ public class FakeApiTest {
* test inline additionalProperties
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testInlineAdditionalPropertiesTest() throws ApiException {
public void testInlineAdditionalPropertiesTest() {
Map<String, String> requestBody = null;
api.testInlineAdditionalProperties(requestBody).block();
@ -207,12 +193,9 @@ public class FakeApiTest {
* test json serialization of form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testJsonFormDataTest() throws ApiException {
public void testJsonFormDataTest() {
String param = null;
String param2 = null;
api.testJsonFormData(param, param2).block();

View File

@ -13,7 +13,6 @@
package org.openapitools.client.api;
import org.openapitools.client.ApiException;
import org.openapitools.client.model.Client;
import org.junit.Test;
import org.junit.Ignore;
@ -36,12 +35,9 @@ public class FakeClassnameTags123ApiTest {
* To test class name in snake case
*
* To test class name in snake case
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testClassnameTest() throws ApiException {
public void testClassnameTest() {
Client client = null;
Client response = api.testClassname(client).block();

View File

@ -13,7 +13,6 @@
package org.openapitools.client.api;
import org.openapitools.client.ApiException;
import java.io.File;
import org.openapitools.client.model.ModelApiResponse;
import org.openapitools.client.model.Pet;
@ -38,12 +37,9 @@ public class PetApiTest {
* Add a new pet to the store
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void addPetTest() throws ApiException {
public void addPetTest() {
Pet pet = null;
api.addPet(pet).block();
@ -54,12 +50,9 @@ public class PetApiTest {
* Deletes a pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void deletePetTest() throws ApiException {
public void deletePetTest() {
Long petId = null;
String apiKey = null;
api.deletePet(petId, apiKey).block();
@ -71,12 +64,9 @@ public class PetApiTest {
* Finds Pets by status
*
* Multiple status values can be provided with comma separated strings
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void findPetsByStatusTest() throws ApiException {
public void findPetsByStatusTest() {
List<String> status = null;
List<Pet> response = api.findPetsByStatus(status).collectList().block();
@ -87,12 +77,9 @@ public class PetApiTest {
* Finds Pets by tags
*
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void findPetsByTagsTest() throws ApiException {
public void findPetsByTagsTest() {
List<String> tags = null;
List<Pet> response = api.findPetsByTags(tags).collectList().block();
@ -103,12 +90,9 @@ public class PetApiTest {
* Find pet by ID
*
* Returns a single pet
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void getPetByIdTest() throws ApiException {
public void getPetByIdTest() {
Long petId = null;
Pet response = api.getPetById(petId).block();
@ -119,12 +103,9 @@ public class PetApiTest {
* Update an existing pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void updatePetTest() throws ApiException {
public void updatePetTest() {
Pet pet = null;
api.updatePet(pet).block();
@ -135,12 +116,9 @@ public class PetApiTest {
* Updates a pet in the store with form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void updatePetWithFormTest() throws ApiException {
public void updatePetWithFormTest() {
Long petId = null;
String name = null;
String status = null;
@ -153,12 +131,9 @@ public class PetApiTest {
* uploads an image
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void uploadFileTest() throws ApiException {
public void uploadFileTest() {
Long petId = null;
String additionalMetadata = null;
File file = null;
@ -171,16 +146,13 @@ public class PetApiTest {
* uploads an image (required)
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void uploadFileWithRequiredFileTest() throws ApiException {
public void uploadFileWithRequiredFileTest() {
Long petId = null;
File file = null;
File requiredFile = null;
String additionalMetadata = null;
ModelApiResponse response = api.uploadFileWithRequiredFile(petId, file, additionalMetadata).block();
ModelApiResponse response = api.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata).block();
// TODO: test validations
}

View File

@ -13,7 +13,6 @@
package org.openapitools.client.api;
import org.openapitools.client.ApiException;
import org.openapitools.client.model.Order;
import org.junit.Test;
import org.junit.Ignore;
@ -36,12 +35,9 @@ public class StoreApiTest {
* Delete purchase order by ID
*
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void deleteOrderTest() throws ApiException {
public void deleteOrderTest() {
String orderId = null;
api.deleteOrder(orderId).block();
@ -52,12 +48,9 @@ public class StoreApiTest {
* Returns pet inventories by status
*
* Returns a map of status codes to quantities
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void getInventoryTest() throws ApiException {
public void getInventoryTest() {
Map<String, Integer> response = api.getInventory().block();
// TODO: test validations
@ -67,12 +60,9 @@ public class StoreApiTest {
* Find purchase order by ID
*
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void getOrderByIdTest() throws ApiException {
public void getOrderByIdTest() {
Long orderId = null;
Order response = api.getOrderById(orderId).block();
@ -83,12 +73,9 @@ public class StoreApiTest {
* Place an order for a pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void placeOrderTest() throws ApiException {
public void placeOrderTest() {
Order order = null;
Order response = api.placeOrder(order).block();

View File

@ -13,7 +13,6 @@
package org.openapitools.client.api;
import org.openapitools.client.ApiException;
import org.openapitools.client.model.User;
import org.junit.Test;
import org.junit.Ignore;
@ -36,12 +35,9 @@ public class UserApiTest {
* Create user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void createUserTest() throws ApiException {
public void createUserTest() {
User user = null;
api.createUser(user).block();
@ -52,12 +48,9 @@ public class UserApiTest {
* Creates list of users with given input array
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void createUsersWithArrayInputTest() throws ApiException {
public void createUsersWithArrayInputTest() {
List<User> user = null;
api.createUsersWithArrayInput(user).block();
@ -68,12 +61,9 @@ public class UserApiTest {
* Creates list of users with given input array
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void createUsersWithListInputTest() throws ApiException {
public void createUsersWithListInputTest() {
List<User> user = null;
api.createUsersWithListInput(user).block();
@ -84,12 +74,9 @@ public class UserApiTest {
* Delete user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void deleteUserTest() throws ApiException {
public void deleteUserTest() {
String username = null;
api.deleteUser(username).block();
@ -100,12 +87,9 @@ public class UserApiTest {
* Get user by user name
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void getUserByNameTest() throws ApiException {
public void getUserByNameTest() {
String username = null;
User response = api.getUserByName(username).block();
@ -116,12 +100,9 @@ public class UserApiTest {
* Logs user into the system
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void loginUserTest() throws ApiException {
public void loginUserTest() {
String username = null;
String password = null;
String response = api.loginUser(username, password).block();
@ -133,12 +114,9 @@ public class UserApiTest {
* Logs out current logged in user session
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void logoutUserTest() throws ApiException {
public void logoutUserTest() {
api.logoutUser().block();
// TODO: test validations
@ -148,12 +126,9 @@ public class UserApiTest {
* 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 {
public void updateUserTest() {
String username = null;
User user = null;
api.updateUser(username, user).block();