Dogma Codegen

Code generation for the Dogma libraries

Build Status Coverage Status Pub Status Stories in Ready

Join the chat at

Release Status

The Dogma Codegen library provides mechanisms to generate source code that interfaces with the Dogma libraries for creating data layers. Using the library is not mandatory, but its usage is recommended as it eliminates the boilerplate code that needs to be written using the libraries.

Dogma Codegen can be used directly to generate source code but it is also leveraged to parse different file formats describing models and full RESTful APIs. Before using Dogma Codegen directly consider using one of those libraries instead as even more code can be automatically generated.

| Library | Models | Unmodifiable Views | Convert | Mapper | Fluent Queries | |--|-|-|-|-|-| | Codegen | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | | JSON Schema | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | | Swagger | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |

Getting Started

Dogma Codegen should be installed as a developer dependency. Add the following to the project's pubspec.yaml.

  dogma_codegen: ^0.0.1

It can also be installed using den by using the following command den install dogma_codegen --dev.

Package Conventions

Dogma Codegen is opinionated on the layout of the package. The following showcases the default structure.

+ lib
  + src
    + models
    + convert

Building the Library

Dogma Codegen uses a build.dart file at the root of the package to generate source code. For packages following the above conventions a working build.dart looks like.

import 'dart:async';
import 'package:dogma_codegen/build.dart';

Future<Null> main(List<String> args) async {
  await build(args);

If the layout of the package is different then view the documentation on the build method and modify the values accordingly. It is however highly recommended to stick with the prescribed layout.

Full Rebuilds

The build.dart file can be invoked directly which will cause a full rebuild of the library.

Incremental Builds

Dogma Codegen supports incremental builds through the build_system library. Any change to the model files will be result in a rebuild when using build_system. See its documentation for the most up to date information on using it. Dogma Codegen will continue to follow the conventions of that library to ensure the built files are up to date with the model definitions.

Example Projects

Working examples of various third-party APIs are available collected at the Dogma Dart APIs Organization. These can be referenced for getting started with the Dogma libraries.

Features and bugs

Please file feature requests and bugs at the issue tracker.



Contains the build function which orchestrates the build process for a library.


Functions for handling identifiers.


Functions for handling uri paths.


Functionality for working with mustache templates.