leancode_contracts_generator 0.17.0 copy "leancode_contracts_generator: ^0.17.0" to clipboard
leancode_contracts_generator: ^0.17.0 copied to clipboard

Dart contracts client generator for a CQRS API.

leancode_contracts_generator #

Installation #

dart pub add leancode_contracts_generator --dev

If your contracts use Topics additionally install leancode_pipe:

dart pub add leancode_pipe

Add dependencies for generating JSON serialization helpers:

dart pub add json_serializable --dev
dart pub add build_runner --dev

Usage #

Ensure that you have .NET SDK installed with version capable of building target contracts project.

The version of .NET generator is controlled using .NET tool manifest (see example), the presence of which is required for .NET generator to be found. If it's missing, one can be created with dotnet tool install dotnet-contracts-generate --create-manifest-if-needed.

First run will take longer due to the need to download external dependencies.

After running the contracts generator, generate the JSON serialization helpers:

dart run build_runner build

CLI #

First initialize a config file filled with defaults with dart run leancode_contracts_generator init, then generate client contracts code with dart run leancode_contracts_generator.

$ dart run leancode_contracts_generator --help
Command line utility for generating dart CQRS contracts

Usage: leancode_contracts_generator <command> [arguments]

Global options:
-h, --help    Print this usage information.

Available commands:
  init   Initialize a config file

Run "leancode_contracts_generator help <command>" for more information about a command.

Library #

import 'dart:io';

import 'package:leancode_contracts_generator/leancode_contracts_generator.dart';

Future<void> main(List<String> arguments) async {
  final generator = ContractsGenerator(
    ContractsGeneratorConfig(
      input: GeneratorScript.path(['ExampleContracts/**']),
      name: 'cool_name',
      output: Directory('lib'),
      extra: '// :)',
      include: RegExp(r'\w+(\.\w+)*'),
    ),
  );

  await generator.writeAll();
}
11
likes
150
points
1.54k
downloads

Publisher

verified publisherleancode.co

Weekly Downloads

Dart contracts client generator for a CQRS API.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

args, code_builder, collection, dart_style, fixnum, meta, path, protobuf, recase, yaml

More

Packages that depend on leancode_contracts_generator