Hi, I wonder if there is a way to hide a parameter when using @ModelAttribute
I have this controller method.
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ApiOperation(value = "test the api", notes = "No notes added", response = UserAPIResponse.class)
@ApiResponse(code = 400, message = "Error")
@ApiImplicitParams({
@ApiImplicitParam(name = "fname", value = "User's first name", required = true, dataType = "string", paramType = "form"),
@ApiImplicitParam(name = "lname", value = "User's last name", required = false, dataType = "string", paramType = "form"),
@ApiImplicitParam(name = "phone", value = "User's phone", required = false, dataType = "string", paramType = "form"),
@ApiImplicitParam(name = "email", value = "User's email", required = true, dataType = "string", paramType = "form"),
@ApiImplicitParam(name = "password", value = "User's password", required = true, dataType = "string", paramType = "form")
})
public UserAPIResponse createPOST(@ModelAttribute UserAPI user) {
return handleCreate(user);
}
here is the UserAPI class
public class UserAPI {
private long userid;
private String fname;
private String lname;
private String email;
private String password;
private String phone;
public long getUserid() {
return userid;
}
public void setUserid(long userid) {
this.userid = userid;
}
...
}
I have used the @ApiModelProperty without no effect.
@ApiModelProperty(hidden=true)
public long getUserid() {
return userid;
}

Also I have added all the parameter entries for all the fields using @ApiImplicitParam but I did this only to change the parameter type using "dataType" to form, is there a way to avoid having to map all the fields to achieve this.
Thanks.
Removing the setter should immediately hide it. Model attributes use only bean properties
Thanks, it worked!
@dilipkrish I add annocation in getter method
@ApiModelProperty(hidden = true,readOnly = true)
public List<User> getUserList() {
return userList;
}
but it not effect.
why to removing the setter method ? setter method is used by other method
Most helpful comment
@dilipkrish I add annocation in getter method
but it not effect.
why to removing the setter method ? setter method is used by other method