Install TYML for VSCode
from the VSCode Marketplace.
Create a file named api.tyml
anywhere.
interface API
Install with the following command (requires Rustβs cargo):
In this example, the server is Rust and the client is TypeScript.
First, create a test crate.
Then generate types using the api.tyml
defined in step 2.
If you see Success!
, it worked.
Add the generated api
plus async-trait
and tokio
to Cargo.toml
:
[]
= { = "./api/" }
= "0.1"
= { = "1", = ["full"] }
Finally, edit main.rs
to implement the API.
use ;
use async_trait;
async
Generate TypeScript types.
Then create main.ts
inside ./api-example-client
and call the API.
;
Run the following commands in the server and client directories respectively.
If the client prints Hello, world!
, it worked.