Disclaimer: I'm fairly new to ServiceStack
Given the following Service:
public class TestService : Service
{
public TestResponse Get(Test request)
{
if (String.IsNullOrEmpty(request.Message))
throw new ArgumentException("Message is required");
return new TestResponse();
}
}
and the following request/response DTO's :
[Route("/test", "GET")]
public class Test : IReturn<TestResponse>
{
public string Message { get; set; }
}
public class TestResponse
{
public IList<Test> TestList { get; set; }
}
I would expect the following response when I try to access /test :
{
"responseStatus": {
"errorCode": "ArgumentException",
"message": "Message is required",
"errors": []
}
}
Instead I get an empty JSON response. It is however returning the correct status code (400 Bad Request).
I thought it would be quite common to name your DTO's in this manner in ServiceStack with Something and then SomethingResponse. To get it to return the exception as a serialized ResponseStatus object I have discovered that I can either rename my request DTO from Test to TestRequest and/or include a ResponseStatus property in my response DTO.
Is this expected behaviour?
Update
I should include that the issue only occurs if the name of my response DTO ends with Response (case sensitive). If my request/response DTO's are called Foo and Bar respectively, I receive a properly formatted JSON response with the error.