mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 14:10:56 +00:00
[Jaxrs-cxf] Add method-level cascaded beanvalidation (@Valid) (#4921)
* add ApiResponse/s to operation #4718 * add method-level cascaded beanvalidation #4847
This commit is contained in:
parent
b89e2e6cc3
commit
43aa4a8569
@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.jaxrs.PATCH;
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
{{/useBeanValidation}}
|
||||
|
||||
@Path("{{^useAnnotatedBasePath}}/{{/useAnnotatedBasePath}}{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}")
|
||||
|
@ -28,7 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
public class {{classname}}ServiceImpl implements {{classname}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParams}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParamsImpl}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
// TODO: Implement...
|
||||
|
||||
{{^vendorExtensions.x-java-is-response-void}}return null;{{/vendorExtensions.x-java-is-response-void}}
|
||||
|
@ -1 +1 @@
|
||||
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
|
||||
{{#isBodyParam}}{{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
|
@ -0,0 +1 @@
|
||||
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
|
@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.jaxrs.PATCH;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Path("/")
|
||||
@Api(value = "/", description = "")
|
||||
@ -31,7 +32,7 @@ public interface FakeApi {
|
||||
@ApiOperation(value = "To test \"client\" model", tags={ "fake", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
||||
public Client testClientModel(Client body);
|
||||
public Client testClientModel(@Valid Client body);
|
||||
|
||||
@POST
|
||||
@Path("/fake")
|
||||
|
@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.jaxrs.PATCH;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Path("/")
|
||||
@Api(value = "/", description = "")
|
||||
@ -31,7 +32,7 @@ public interface PetApi {
|
||||
@ApiOperation(value = "Add a new pet to the store", tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input") })
|
||||
public void addPet(Pet body);
|
||||
public void addPet(@Valid Pet body);
|
||||
|
||||
@DELETE
|
||||
@Path("/pet/{petId}")
|
||||
@ -78,7 +79,7 @@ public interface PetApi {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ApiResponse(code = 404, message = "Pet not found"),
|
||||
@ApiResponse(code = 405, message = "Validation exception") })
|
||||
public void updatePet(Pet body);
|
||||
public void updatePet(@Valid Pet body);
|
||||
|
||||
@POST
|
||||
@Path("/pet/{petId}")
|
||||
|
@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.jaxrs.PATCH;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Path("/")
|
||||
@Api(value = "/", description = "")
|
||||
@ -57,6 +58,6 @@ public interface StoreApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||
@ApiResponse(code = 400, message = "Invalid Order") })
|
||||
public Order placeOrder(Order body);
|
||||
public Order placeOrder(@Valid Order body);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.jaxrs.PATCH;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Path("/")
|
||||
@Api(value = "/", description = "")
|
||||
@ -29,7 +30,7 @@ public interface UserApi {
|
||||
@ApiOperation(value = "Create user", tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
public void createUser(User body);
|
||||
public void createUser(@Valid User body);
|
||||
|
||||
@POST
|
||||
@Path("/user/createWithArray")
|
||||
@ -37,7 +38,7 @@ public interface UserApi {
|
||||
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
public void createUsersWithArrayInput(List<User> body);
|
||||
public void createUsersWithArrayInput(@Valid List<User> body);
|
||||
|
||||
@POST
|
||||
@Path("/user/createWithList")
|
||||
@ -45,7 +46,7 @@ public interface UserApi {
|
||||
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
public void createUsersWithListInput(List<User> body);
|
||||
public void createUsersWithListInput(@Valid List<User> body);
|
||||
|
||||
@DELETE
|
||||
@Path("/user/{username}")
|
||||
@ -90,6 +91,6 @@ public interface UserApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid user supplied"),
|
||||
@ApiResponse(code = 404, message = "User not found") })
|
||||
public void updateUser(@PathParam("username") String username, User body);
|
||||
public void updateUser(@Valid @PathParam("username") String username, User body);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void addPetTest() {
|
||||
Pet body = null;
|
||||
//api.addPet(body);
|
||||
//api.addPet(body);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -99,7 +99,7 @@ public class PetApiTest {
|
||||
public void deletePetTest() {
|
||||
Long petId = null;
|
||||
String apiKey = null;
|
||||
//api.deletePet(petId, apiKey);
|
||||
//api.deletePet(petId, apiKey);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -153,7 +153,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void getPetByIdTest() {
|
||||
Long petId = null;
|
||||
//Pet response = api.getPetById(petId);
|
||||
//Pet response = api.getPetById(petId);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
@ -171,7 +171,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void updatePetTest() {
|
||||
Pet body = null;
|
||||
//api.updatePet(body);
|
||||
//api.updatePet(body);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -191,7 +191,7 @@ public class PetApiTest {
|
||||
Long petId = null;
|
||||
String name = null;
|
||||
String status = null;
|
||||
//api.updatePetWithForm(petId, name, status);
|
||||
//api.updatePetWithForm(petId, name, status);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -211,7 +211,7 @@ public class PetApiTest {
|
||||
Long petId = null;
|
||||
String additionalMetadata = null;
|
||||
org.apache.cxf.jaxrs.ext.multipart.Attachment file = null;
|
||||
//ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
|
||||
//ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class StoreApiTest {
|
||||
@Test
|
||||
public void deleteOrderTest() {
|
||||
String orderId = null;
|
||||
//api.deleteOrder(orderId);
|
||||
//api.deleteOrder(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -114,7 +114,7 @@ public class StoreApiTest {
|
||||
@Test
|
||||
public void getOrderByIdTest() {
|
||||
Long orderId = null;
|
||||
//Order response = api.getOrderById(orderId);
|
||||
//Order response = api.getOrderById(orderId);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
@ -132,7 +132,7 @@ public class StoreApiTest {
|
||||
@Test
|
||||
public void placeOrderTest() {
|
||||
Order body = null;
|
||||
//Order response = api.placeOrder(body);
|
||||
//Order response = api.placeOrder(body);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void createUserTest() {
|
||||
User body = null;
|
||||
//api.createUser(body);
|
||||
//api.createUser(body);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -97,7 +97,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void createUsersWithArrayInputTest() {
|
||||
List<User> body = null;
|
||||
//api.createUsersWithArrayInput(body);
|
||||
//api.createUsersWithArrayInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -115,7 +115,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void createUsersWithListInputTest() {
|
||||
List<User> body = null;
|
||||
//api.createUsersWithListInput(body);
|
||||
//api.createUsersWithListInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -133,7 +133,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void deleteUserTest() {
|
||||
String username = null;
|
||||
//api.deleteUser(username);
|
||||
//api.deleteUser(username);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -151,7 +151,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void getUserByNameTest() {
|
||||
String username = null;
|
||||
//User response = api.getUserByName(username);
|
||||
//User response = api.getUserByName(username);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
@ -170,7 +170,7 @@ public class UserApiTest {
|
||||
public void loginUserTest() {
|
||||
String username = null;
|
||||
String password = null;
|
||||
//String response = api.loginUser(username, password);
|
||||
//String response = api.loginUser(username, password);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
@ -187,7 +187,7 @@ public class UserApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void logoutUserTest() {
|
||||
//api.logoutUser();
|
||||
//api.logoutUser();
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
@ -206,7 +206,7 @@ public class UserApiTest {
|
||||
public void updateUserTest() {
|
||||
String username = null;
|
||||
User body = null;
|
||||
//api.updateUser(username, body);
|
||||
//api.updateUser(username, body);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user