Add File support + some fixes to Play generator (#5263)

* First commit of the Java Play Framework server generator. It is highly based on Spring so there might me a couple of things that don't make sense (like options or parameters) for the Play Framework.

* Fix suggestions in the PR discussion + add .bat and .sh file as requested.

* Updated Readme.md file

* Remove unused mustache file + fix baseName vs paramName in all the mustache files.

* Fix the compilation error when we have a body which is a list or map. Doesn't fix the problem with the annotation itself.

* Fix the problem with the Http.MultipartFormData.FilePart

* Return a FileInputStream when the returnType is "file" + Fix a couple of other bugs with boolean + updated sample

* Return an InputStream instead of FileInputStream (except in the instantiation)

* A little cleanup for the form param of type file.
This commit is contained in:
Jean-François Côté
2017-04-10 11:23:28 -04:00
committed by wing328
parent aef98f464e
commit 2e46bb9b9f
12 changed files with 46 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
package controllers;
import java.io.File;
import java.io.InputStream;
import apimodels.Pet;
import play.mvc.Controller;

View File

@@ -1,50 +1,59 @@
package controllers;
import java.io.File;
import java.io.InputStream;
import apimodels.Pet;
import play.mvc.Http;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.FileInputStream;
import javax.validation.constraints.*;
public class PetApiControllerImp implements PetApiControllerImpInterface {
@Override
public void addPet(Pet body) throws Exception {
//Do your magic!!!
}
@Override
public void deletePet(Long petId, String apiKey) throws Exception {
//Do your magic!!!
}
@Override
public List<Pet> findPetsByStatus( List<String> status) throws Exception {
//Do your magic!!!
return new ArrayList<Pet>();
}
@Override
public List<Pet> findPetsByTags( List<String> tags) throws Exception {
//Do your magic!!!
return new ArrayList<Pet>();
}
@Override
public Pet getPetById(Long petId) throws Exception {
//Do your magic!!!
return new Pet();
}
@Override
public void updatePet(Pet body) throws Exception {
//Do your magic!!!
}
@Override
public void updatePetWithForm(String petId, String name, String status) throws Exception {
//Do your magic!!!
}
@Override
public void uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
//Do your magic!!!

View File

@@ -1,6 +1,6 @@
package controllers;
import java.io.File;
import java.io.InputStream;
import apimodels.Pet;
import play.mvc.Http;

View File

@@ -7,24 +7,29 @@ import play.mvc.Http;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.FileInputStream;
import javax.validation.constraints.*;
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
@Override
public void deleteOrder(String orderId) throws Exception {
//Do your magic!!!
}
@Override
public Map<String, Integer> getInventory() throws Exception {
//Do your magic!!!
return new HashMap<String, Integer>();
}
@Override
public Order getOrderById(String orderId) throws Exception {
//Do your magic!!!
return new Order();
}
@Override
public Order placeOrder(Order body) throws Exception {
//Do your magic!!!
return new Order();

View File

@@ -7,44 +7,53 @@ import play.mvc.Http;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.FileInputStream;
import javax.validation.constraints.*;
public class UserApiControllerImp implements UserApiControllerImpInterface {
@Override
public void createUser(User body) throws Exception {
//Do your magic!!!
}
@Override
public void createUsersWithArrayInput(List<User> body) throws Exception {
//Do your magic!!!
}
@Override
public void createUsersWithListInput(List<User> body) throws Exception {
//Do your magic!!!
}
@Override
public void deleteUser(String username) throws Exception {
//Do your magic!!!
}
@Override
public User getUserByName(String username) throws Exception {
//Do your magic!!!
return new User();
}
@Override
public String loginUser( String username, String password) throws Exception {
//Do your magic!!!
return new String();
}
@Override
public void logoutUser() throws Exception {
//Do your magic!!!
}
@Override
public void updateUser(String username, User body) throws Exception {
//Do your magic!!!