Typically if I wanted to validate a JSON response I would create DTOs and use a library to parse the response into a DTO class. If the parse fails then I can confirm the format of the response body is invalid.
The problem is I want to dynamically configure API endpoints to hit and dynamically configure a way to validate the format of the JSON response. Is there a good way to accomplish this?
config.json
{
{
"url": "http://www.example.com/api/v1/test1",
"response": (expected Dto1)
},
{
"url": "http://www.example.com/api/v1/test2",
"response": (expected Dto2)
}
}