Web-Anchor
Web-Anchor copied to clipboard
Handling different cases
It would be nice if you could pass the case (i.e. camelCase, snake_case etc.) of the api as a parameter, or even better if WebAnchor could recognize it automatically.
The default serializer is the JSON.NET JsonSerializer which has a ContractResolver-property that can be used to change how json is serialized (like the CamelCasePropertyNamesContractResolver). So this can be applied for web anchor like this:
var myApi = Api.For<ITestApi>(host, new ApiSettings
{
ContentSerializer = new ContentSerializer(new JsonSerializer
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
})
});
In this case I know it is about deserializing. The same JsonSerializer that Carl suggests can be used when creating the response parser as well.
Maybe we should be clearer on where to modify serialization. The name ContentSerializer does really reveal wheather it is used for Request content serialization or Reponse content serialization...
Also changing reponse serialization is little bit harder to get to in order to change it (if you don't know where to look), but that's easily solved by documentation