[Java Play Framework] Remove most warnings + bug fixes (#6275)

* Removals of most of the warnings found by lint

* Removals of most of the warnings found by lint (PART 2)

* Removals of most of the warnings found by lint (PART 3)

* Removals of most of the warnings found by lint (PART 4)

* Removals of most of the warnings found by lint (PART 5)

* Fix conversion error

* Removal of unnecessary import. Other will need more complex login in the generator itself (not in the mustache files)

* Add missing imports + fix to the regex. Generation of the samples
This commit is contained in:
Jean-François Côté
2017-08-11 03:38:18 -04:00
committed by wing328
parent b0333af8bd
commit ab28c7c825
140 changed files with 849 additions and 874 deletions

View File

@@ -13,7 +13,7 @@ import java.util.ArrayList;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.inject.Inject;
import java.io.IOException;
import java.io.File;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -41,9 +41,7 @@ public class PetApiController extends Controller {
body = mapper.readValue(nodebody.toString(), Pet.class);
imp.addPet(body);
return ok();
}
@ApiAction
@@ -51,15 +49,13 @@ public class PetApiController extends Controller {
String valueapiKey = request().getHeader("api_key");
String apiKey;
if (valueapiKey != null) {
apiKey = (String)valueapiKey;
apiKey = valueapiKey;
} else {
apiKey = null;
}
imp.deletePet(petId, apiKey);
return ok();
}
@ApiAction
@@ -73,8 +69,6 @@ public class PetApiController extends Controller {
List<Pet> obj = imp.findPetsByStatus(status);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -88,8 +82,6 @@ public class PetApiController extends Controller {
List<Pet> obj = imp.findPetsByTags(tags);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -97,8 +89,6 @@ public class PetApiController extends Controller {
Pet obj = imp.getPetById(petId);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -109,9 +99,7 @@ public class PetApiController extends Controller {
body = mapper.readValue(nodebody.toString(), Pet.class);
imp.updatePet(body);
return ok();
}
@ApiAction
@@ -119,7 +107,7 @@ public class PetApiController extends Controller {
String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
String name;
if (valuename != null) {
name = (String)valuename;
name = valuename;
} else {
name = null;
@@ -127,15 +115,13 @@ public class PetApiController extends Controller {
String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
String status;
if (valuestatus != null) {
status = (String)valuestatus;
status = valuestatus;
} else {
status = null;
}
imp.updatePetWithForm(petId, name, status);
return ok();
}
@ApiAction
@@ -143,16 +129,14 @@ public class PetApiController extends Controller {
String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
String additionalMetadata;
if (valueadditionalMetadata != null) {
additionalMetadata = (String)valueadditionalMetadata;
additionalMetadata = valueadditionalMetadata;
} else {
additionalMetadata = null;
}
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
}

View File

@@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.HashMap;
@SuppressWarnings("RedundantThrows")
public interface PetApiControllerImpInterface {
void addPet(Pet body) throws Exception;

View File

@@ -12,7 +12,7 @@ import java.util.ArrayList;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.inject.Inject;
import java.io.IOException;
import java.io.File;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -35,9 +35,7 @@ public class StoreApiController extends Controller {
@ApiAction
public Result deleteOrder(String orderId) throws Exception {
imp.deleteOrder(orderId);
return ok();
}
@ApiAction
@@ -45,8 +43,6 @@ public class StoreApiController extends Controller {
Map<String, Integer> obj = imp.getInventory();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -54,8 +50,6 @@ public class StoreApiController extends Controller {
Order obj = imp.getOrderById(orderId);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -68,7 +62,5 @@ public class StoreApiController extends Controller {
Order obj = imp.placeOrder(body);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
}

View File

@@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.HashMap;
@SuppressWarnings("RedundantThrows")
public interface StoreApiControllerImpInterface {
void deleteOrder(String orderId) throws Exception;

View File

@@ -12,7 +12,7 @@ import java.util.ArrayList;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.inject.Inject;
import java.io.IOException;
import java.io.File;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -40,9 +40,7 @@ public class UserApiController extends Controller {
body = mapper.readValue(nodebody.toString(), User.class);
imp.createUser(body);
return ok();
}
@ApiAction
@@ -53,9 +51,7 @@ public class UserApiController extends Controller {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
imp.createUsersWithArrayInput(body);
return ok();
}
@ApiAction
@@ -66,17 +62,13 @@ public class UserApiController extends Controller {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
imp.createUsersWithListInput(body);
return ok();
}
@ApiAction
public Result deleteUser(String username) throws Exception {
imp.deleteUser(username);
return ok();
}
@ApiAction
@@ -84,8 +76,6 @@ public class UserApiController extends Controller {
User obj = imp.getUserByName(username);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -93,26 +83,22 @@ public class UserApiController extends Controller {
String valueusername = request().getQueryString("username");
String username;
username = (String)valueusername;
username = valueusername;
String valuepassword = request().getQueryString("password");
String password;
password = (String)valuepassword;
password = valuepassword;
String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
public Result logoutUser() throws Exception {
imp.logoutUser();
return ok();
}
@ApiAction
@@ -123,8 +109,6 @@ public class UserApiController extends Controller {
body = mapper.readValue(nodebody.toString(), User.class);
imp.updateUser(username, body);
return ok();
}
}

View File

@@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.HashMap;
@SuppressWarnings("RedundantThrows")
public interface UserApiControllerImpInterface {
void createUser(User body) throws Exception;