Skip to content


Serializers are employed to transform the controller's response before sending it as an HTTP response.

Create a serializer

dox create:serializer Blog


class BlogSerializer extends Serializer<Blog> {

    Map<String, dynamic> convert(Blog m) {
        return {
            'title_en' : m.title,
class BlogController {
    getAllBlogs(DoxRequest req) async {
        List<Blog> blogs = await Blog().all();

        /// you can pass as list of data
        return BlogSerializer(blogs);

    findBlog(DoxRequest req, id) async {
        Blog blog = await Blog().find(id);

        /// or you can also pass as single data
        return BlogSerializer(blog);
    "uid" : "1",
    "title_en": "This is title"


You can pass as list of data or single data into the serializer. Just make sure that you have injected your model type in serializer Serializer<Blog>.