Adds serialization API to directive