Define custom serializer for a resource