0

I have a REST service that takes an object containing an enum field as input. When a value not present in the enum is passed to me in input, a BAD REQUEST is automatically launched. I tried to go into debug to see where to handle the error but I notice that it doesn't really enter the method.

Retrieve interface:

@POST
@Path("/retrieve")
public Response retrieveValue(@Valid User user);

User:

public class User(){
  String name;
  String surname;
  CityEnum city;

  // getter and setter whith @NotNull annotation
}

CityEnum:

public enum CityEnum(){
   LONDON("London"),
   LIVERPOOL("Liverpool"),
   ...

  private String city;
}

I need to return an error message and I assume the handling will be done in the RetrieveService which implements the Retrieve interface. How can this be done? I am using Mricroprofile.

Prodox21
  • 107
  • 1
  • 2
  • 9
  • have you seen https://stackoverflow.com/a/64576320/175554 ? – ozkanpakdil Oct 16 '21 at 14:48
  • The solution described concerns @ControllerAdvice which is part of Spring, I am using Microprofile. Https://www.baeldung.com/javax-validations-enums is also linked, I tried what is described in point 4 but it doesn't work. – Prodox21 Oct 18 '21 at 14:47
  • can you put a reproducer to github? – ozkanpakdil Oct 18 '21 at 18:27
  • Sorry but I don't have github, I have better described my problem here: https://stackoverflow.com/questions/69619208/validations-for-enum-types-java-microprofile. I was unable to modify my application and therefore I opened another one – Prodox21 Oct 19 '21 at 08:14
  • no, this is my question related to this problem where i show how i tried to find a solution without success – Prodox21 Oct 19 '21 at 15:57

0 Answers0