I am creating a notification tool which supports multiple notifications. Each notification type has some mandatory fields. Ex:
class EmailParam {
@NotEmpty
private List<String> emailIds;
}
class JiraParam {
@NotNull
private String issueType;
@NotNull
private String project;
private List<String> watchers;
}
My Rest API would take the notification type and the parameters as the JSON request body. What would be the best way to show the client, which are the mandatory parameters with their field types for a notification type? I am confused on whether I should use Jackson to get the fields and expose them via an API. Sample rest api:
POST /alert/1
{
notificationTypes: [email, jira],
emailIds: [test@domain.com],
issueType: task,
project: notify,
watchers: []
}
POST /alert/2
{
notificationTypes: [email],
emailIds: [test@domain.com]
}
Also, do I have to use a custom validator, or can I use somehow use Hibernate's validator in this case?
Aucun commentaire:
Enregistrer un commentaire