Ich benutze Dropwizard und habe einen Service, der sowohl Json und Protobuf unterstützt. Ich mag die @ Valid-Notation und Anmerkung zu Feldern in meinen Anfrageklassen. Problem ist, dass die @ Valid-Notation nur für Json und nicht für Protobuf funktioniert. Gibt es einen Weg oder einen guten Ansatz dafür, wie die @Valid-Annotation unabhängig vom Medientyp funktioniert?Dropwizard Protobuf Validierung
Beispiel Service:
@POST
@Produces({
MediaType.APPLICATION_JSON, "application/x-protobuf"
})
@Consumes({
MediaType.APPLICATION_JSON, "application/x-protobuf"
})
@Path("/foo")
void foo(@Valid Request request);
public class Request
{
@NotBlank(message = "Missing info")
String field;
}