]> Untitled Git - lemmy.git/commitdiff
docs(api): Add api-common info on generating TypeScript bindings (#3330)
authorJan Klass <kissaki@posteo.de>
Wed, 28 Jun 2023 09:25:46 +0000 (11:25 +0200)
committerGitHub <noreply@github.com>
Wed, 28 Jun 2023 09:25:46 +0000 (11:25 +0200)
crates/api_common/README.md

index bf916bf0c2b1d036855e3fb5607c3d57415e609c..f6a16c53cc9ed04184f537622fdf4ac3f3468496 100644 (file)
@@ -24,3 +24,10 @@ As you can see, each API endpoint needs a parameter type ( GetPosts), path (/pos
 For a real example of a Lemmy API client, look at [lemmyBB](https://github.com/LemmyNet/lemmyBB/tree/main/src/api).
 
 Lemmy also provides a websocket API. You can find the full websocket code in [this file](https://github.com/LemmyNet/lemmy/blob/main/src/api_routes_websocket.rs).
 For a real example of a Lemmy API client, look at [lemmyBB](https://github.com/LemmyNet/lemmyBB/tree/main/src/api).
 
 Lemmy also provides a websocket API. You can find the full websocket code in [this file](https://github.com/LemmyNet/lemmy/blob/main/src/api_routes_websocket.rs).
+
+## Generate TypeScript bindings
+
+TypeScript bindings (API types) can be generated by running `cargo test --features full`.
+The ts files be generated into a `bindings` folder.
+
+This crate uses [`ts_rs`](https://docs.rs/ts-rs/6.2.1/ts_rs/#traits) macros `derive(TS)` and `ts(export)` to attribute types for binding generating.