'how to validate if body request schema is same as in swagger api?
i need to create a controller that expose checkCustomer service that recive a body of Customer Object and the function check Customer should check if the json schema that i got in the body request is the same like in swagger api documentation and return success or fail i can't find how to do this checking please someone help here is some of my code that i tried :
@Service
public class CustomerService implements CustomerServiceInter {
@Override
public String checkCustomer(Customer customer) throws JsonProcessingException {
OpenAPI openAPI = new OpenAPI();
MessageResolver messageResolver = new MessageResolver();
SchemaValidator schemaValidator = new SchemaValidator(openAPI, messageResolver);
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(customer);
ValidationReport validate = schemaValidator.validate("customer", json , "prefix");
System.out.println(validate);
return null;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
