{"id":17602587,"url":"https://github.com/skycoder42/json_rpc_codegen","last_synced_at":"2025-07-26T17:06:03.482Z","repository":{"id":203027116,"uuid":"696366240","full_name":"Skycoder42/json_rpc_codegen","owner":"Skycoder42","description":"A dart code generator that generates typed client and server code for the json_rpc_2 package.","archived":false,"fork":false,"pushed_at":"2023-12-15T06:11:45.000Z","size":173,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T22:13:49.078Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Skycoder42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-25T15:46:19.000Z","updated_at":"2024-11-19T10:39:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"e749d104-535c-439e-8eb4-d94c562a99df","html_url":"https://github.com/Skycoder42/json_rpc_codegen","commit_stats":null,"previous_names":["skycoder42/json_rpc_codegen"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Skycoder42/json_rpc_codegen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skycoder42%2Fjson_rpc_codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skycoder42%2Fjson_rpc_codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skycoder42%2Fjson_rpc_codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skycoder42%2Fjson_rpc_codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Skycoder42","download_url":"https://codeload.github.com/Skycoder42/json_rpc_codegen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skycoder42%2Fjson_rpc_codegen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267198672,"owners_count":24051559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-22T13:08:58.537Z","updated_at":"2025-07-26T17:06:03.461Z","avatar_url":"https://github.com/Skycoder42.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json_rpc_codegen\n[![CI/CD for json_rpc_codegen](https://github.com/Skycoder42/json_rpc_codegen/actions/workflows/json_rpc_codegen_ci.yaml/badge.svg)](https://github.com/Skycoder42/json_rpc_codegen/actions/workflows/json_rpc_codegen_ci.yaml)\n[![CI/CD for json_rpc_codegen_builder](https://github.com/Skycoder42/json_rpc_codegen/actions/workflows/json_rpc_codegen_builder_ci.yaml/badge.svg)](https://github.com/Skycoder42/json_rpc_codegen/actions/workflows/json_rpc_codegen_builder_ci.yaml)\n[![json_rpc_codegen pub version](https://img.shields.io/pub/v/json_rpc_codegen?label=pub%20-%20json_rpc_codegen)](https://pub.dev/packages/json_rpc_codegen)\n[![json_rpc_codegen_builder pub version](https://img.shields.io/pub/v/json_rpc_codegen_builder?label=pub%20-%20json_rpc_codegen_builder)](https://pub.dev/packages/json_rpc_codegen_builder)\n\nA dart code generator that generates typed client and server code for the json_rpc_2 package.\n\n## Table of Contents\n\n## Features\n- Code generator for the [json_rpc_2](https://pub.dev/packages/json_rpc_2) package (The official JSON-RPC 2.0\nimplementation for dart)\n- Creates Client and Server classes, as well as Mixins\n  - You can directly use the Client/Server classes for simple usecases\n  - If you need to work with Peers, or if you want to have a single server/client instance that provides/consumes\n  multiple definitions, you can creates those by using the base class and the mixins\n- Supports all basic dart types and custom JSON serializables as well\n  - Can handle primitive types (bool, int, ...)\n  - Can handle infinitely nested containes (List, Set, Map, ...)\n  - Can handle infinitely nested records\n  - Can handle advanced dart types (DateTime, Uri)\n  - Can handle custom types via `fromJson` and `toJson` methods\n- Methods can define typed named or positional parameters\n  - All types supported\n  - With server-sided JSON validation\n  - Default-Values are supported (Client or Server-Sided)\n\n## Installation\nAs this is a builder package, you need to also install the annotations and build_runner:\n\n```yaml\ndependencies:\n  json_rpc_codegen: \u003clatest\u003e\n\ndev_dependencies:\n  build_runner: \u003clatest\u003e\n  json_rpc_codegen_builder: \u003clatest\u003e\n```\n\n## Usage\nThe API usage is very basic. You create an abstract dart class that describes the interface, and the code generator\nwill do the rest for you:\n\n```dart\nimport 'package:json_rpc_codegen/json_rpc_codegen.dart';\n\npart 'my_class.g.dart';\n\nenum Stage { all, pre, post }\n\n@jsonRpc\nabstract class _MyClass {\n  void startServerTask({\n    required int id,\n    required String taskName,\n    bool verbose = false,\n    double? scale,\n  });\n\n  @clientDefaults\n  double getProgress(int id, [Stage stage = Stage.all]);\n}\n```\n\nThis will generate a bunch of code for both, the client and the server implementation. Have a look at the documentation\non how to control which of these classes get generated. By default, the following will be generated:\n\n- `MyClassClientMixin`: A Mixin on the `ClientBase` class that has all the client implementations of the interface\n- `MyClassServerMixin`: A Mixin on the `ServerBase` class that has all the server implementations of the interface\n- `MyClassClient`: A class that uses the `MyClassClientMixin`, ready for use\n- `MyClassServer`: A class that uses the `MyClassServerMixin`, ready for use\n\nIn most cases, you will want to use `MyClassClient` and `MyClassServer` directly. However, if you want to combine\nmultiple interfaces into one, or if you are working with `Peer`s, you may want to use the mixins instead.\n\nHere is a simplified example, of how the generated classes look:\n\n```dart\nclass MyClassClient {\n  void startServerTask({\n    required int id,\n    required String taskName,\n    // all optional parameters are nullable, as the defaults are managed by the server\n    bool? verbose,\n    double? scale,\n  });\n\n  // non-void methods become futures to wait for the result\n  Future\u003cdouble\u003e getProgress(\n    int id, [\n    // client defaults are set on the client instead\n    Stage stage = Stage.all,\n  ]);\n}\n\n// The server is abstract, as you need to implement the logic of the server methods\nabstract class MyClassServer {\n  // All server methods use FutureOr and can be synchronous or asynchronous\n  @protected\n  FutureOr\u003cvoid\u003e startServerTask(\n    int id,\n    String taskName,\n    // server defaults are set by the implementation\n    bool verbose,\n    double? scale,\n  );\n\n  @protected\n  FutureOr\u003cdouble\u003e getProgress(\n    int id,\n    // client defaults are required on the server side\n    Stage stage,\n  );\n}\n```\n\nTo use the client, simply create a new instance, just as you would with the standard `json_rpc_2` client. For the\nserver, create your own server class that extends the generated server to implement the server methods. Then you can\nuse this class just like the `json_rpc_2`, but without you having to take care of any registrations.\n\n## Documentation\nThe documentation is available at https://pub.dev/documentation/json_rpc_codegen/latest/. A full example can be found\nat https://pub.dev/packages/json_rpc_codegen_builder/example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskycoder42%2Fjson_rpc_codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskycoder42%2Fjson_rpc_codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskycoder42%2Fjson_rpc_codegen/lists"}