mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
fix inner item (list, map) for play framework (#217)
This commit is contained in:
parent
c8c316e41e
commit
2c6380c846
@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaPlayFramework -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l java-play-framework -o samples/server/petstore/java-play-framework -DhideGenerationTimestamp=true"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/JavaPlayFramework -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l java-play-framework -o samples/server/petstore/java-play-framework -DhideGenerationTimestamp=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
@ -69,12 +69,12 @@ public class {{classname}}Controller extends Controller {
|
||||
{{#useBeanValidation}}
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
{{#isListContainer}}
|
||||
for ({{{baseType}}} curItem : {{paramName}}) {
|
||||
for ({{{items.baseType}}} curItem : {{paramName}}) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
for (Map.Entry<String, {{{baseType}}}> entry : {{paramName}}.entrySet()) {
|
||||
for (Map.Entry<String, {{{items.baseType}}}> entry : {{paramName}}.entrySet()) {
|
||||
SwaggerUtils.validate(entry.getValue());
|
||||
}
|
||||
{{/isMapContainer}}
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
@ -10,6 +10,6 @@ public class ApiDocController extends Controller {
|
||||
}
|
||||
|
||||
public Result api() {
|
||||
return redirect("/assets/lib/swagger-ui/index.html?/url=/assets/swagger.json");
|
||||
return redirect("/assets/lib/swagger-ui/index.html?/url=/assets/openapi.json");
|
||||
}
|
||||
}
|
||||
|
@ -39,17 +39,17 @@ public class PetApiController extends Controller {
|
||||
|
||||
@ApiAction
|
||||
public Result addPet() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
Pet body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
JsonNode nodepet = request().body().asJson();
|
||||
Pet pet;
|
||||
if (nodepet != null) {
|
||||
pet = mapper.readValue(nodepet.toString(), Pet.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
SwaggerUtils.validate(pet);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'Pet' parameter is required");
|
||||
}
|
||||
imp.addPet(body);
|
||||
imp.addPet(pet);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ -126,17 +126,17 @@ public class PetApiController extends Controller {
|
||||
|
||||
@ApiAction
|
||||
public Result updatePet() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
Pet body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
JsonNode nodepet = request().body().asJson();
|
||||
Pet pet;
|
||||
if (nodepet != null) {
|
||||
pet = mapper.readValue(nodepet.toString(), Pet.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
SwaggerUtils.validate(pet);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'Pet' parameter is required");
|
||||
}
|
||||
imp.updatePet(body);
|
||||
imp.updatePet(pet);
|
||||
return ok();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import javax.validation.constraints.*;
|
||||
|
||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public void addPet(Pet body) throws Exception {
|
||||
public void addPet(Pet pet) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePet(Pet body) throws Exception {
|
||||
public void updatePet(Pet pet) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import javax.validation.constraints.*;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface PetApiControllerImpInterface {
|
||||
void addPet(Pet body) throws Exception;
|
||||
void addPet(Pet pet) throws Exception;
|
||||
|
||||
void deletePet(Long petId, String apiKey) throws Exception;
|
||||
|
||||
@ -23,7 +23,7 @@ public interface PetApiControllerImpInterface {
|
||||
|
||||
Pet getPetById(Long petId) throws Exception;
|
||||
|
||||
void updatePet(Pet body) throws Exception;
|
||||
void updatePet(Pet pet) throws Exception;
|
||||
|
||||
void updatePetWithForm(Long petId, String name, String status) throws Exception;
|
||||
|
||||
|
@ -61,17 +61,17 @@ public class StoreApiController extends Controller {
|
||||
|
||||
@ApiAction
|
||||
public Result placeOrder() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
Order body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Order.class);
|
||||
JsonNode nodeorder = request().body().asJson();
|
||||
Order order;
|
||||
if (nodeorder != null) {
|
||||
order = mapper.readValue(nodeorder.toString(), Order.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
SwaggerUtils.validate(order);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'Order' parameter is required");
|
||||
}
|
||||
Order obj = imp.placeOrder(body);
|
||||
Order obj = imp.placeOrder(order);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
SwaggerUtils.validate(obj);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order placeOrder(Order body) throws Exception {
|
||||
public Order placeOrder(Order order) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new Order();
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ public interface StoreApiControllerImpInterface {
|
||||
|
||||
Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception;
|
||||
|
||||
Order placeOrder(Order body) throws Exception;
|
||||
Order placeOrder(Order order) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -38,53 +38,53 @@ public class UserApiController extends Controller {
|
||||
|
||||
@ApiAction
|
||||
public Result createUser() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
User body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
JsonNode nodeuser = request().body().asJson();
|
||||
User user;
|
||||
if (nodeuser != null) {
|
||||
user = mapper.readValue(nodeuser.toString(), User.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
SwaggerUtils.validate(user);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'User' parameter is required");
|
||||
}
|
||||
imp.createUser(body);
|
||||
imp.createUser(user);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result createUsersWithArrayInput() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
List<User> body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
JsonNode nodeuser = request().body().asJson();
|
||||
List<User> user;
|
||||
if (nodeuser != null) {
|
||||
user = mapper.readValue(nodeuser.toString(), new TypeReference<List<User>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (User curItem : body) {
|
||||
for (User curItem : user) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'User' parameter is required");
|
||||
}
|
||||
imp.createUsersWithArrayInput(body);
|
||||
imp.createUsersWithArrayInput(user);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result createUsersWithListInput() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
List<User> body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
JsonNode nodeuser = request().body().asJson();
|
||||
List<User> user;
|
||||
if (nodeuser != null) {
|
||||
user = mapper.readValue(nodeuser.toString(), new TypeReference<List<User>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (User curItem : body) {
|
||||
for (User curItem : user) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'User' parameter is required");
|
||||
}
|
||||
imp.createUsersWithListInput(body);
|
||||
imp.createUsersWithListInput(user);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ -133,17 +133,17 @@ public class UserApiController extends Controller {
|
||||
|
||||
@ApiAction
|
||||
public Result updateUser(String username) throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
User body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
JsonNode nodeuser = request().body().asJson();
|
||||
User user;
|
||||
if (nodeuser != null) {
|
||||
user = mapper.readValue(nodeuser.toString(), User.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
SwaggerUtils.validate(user);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
throw new IllegalArgumentException("'User' parameter is required");
|
||||
}
|
||||
imp.updateUser(username, body);
|
||||
imp.updateUser(username, user);
|
||||
return ok();
|
||||
}
|
||||
}
|
||||
|
@ -12,17 +12,17 @@ import javax.validation.constraints.*;
|
||||
|
||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
@Override
|
||||
public void createUser(User body) throws Exception {
|
||||
public void createUser(User user) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUsersWithArrayInput(List<User> body) throws Exception {
|
||||
public void createUsersWithArrayInput(List<User> user) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUsersWithListInput(List<User> body) throws Exception {
|
||||
public void createUsersWithListInput(List<User> user) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(String username, User body) throws Exception {
|
||||
public void updateUser(String username, User user) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,11 @@ import javax.validation.constraints.*;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface UserApiControllerImpInterface {
|
||||
void createUser(User body) throws Exception;
|
||||
void createUser(User user) throws Exception;
|
||||
|
||||
void createUsersWithArrayInput(List<User> body) throws Exception;
|
||||
void createUsersWithArrayInput(List<User> user) throws Exception;
|
||||
|
||||
void createUsersWithListInput(List<User> body) throws Exception;
|
||||
void createUsersWithListInput(List<User> user) throws Exception;
|
||||
|
||||
void deleteUser(String username) throws Exception;
|
||||
|
||||
@ -26,6 +26,6 @@ public interface UserApiControllerImpInterface {
|
||||
|
||||
void logoutUser() throws Exception;
|
||||
|
||||
void updateUser(String username, User body) throws Exception;
|
||||
void updateUser(String username, User user) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
name := """swagger-java-playframework"""
|
||||
name := """openapi-java-playframework"""
|
||||
|
||||
version := "1.0-SNAPSHOT"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user