my-clients (0.1.0)
Installation
[registries.forgejo]
index = "sparse+ " # Sparse index
# index = " " # Git
[net]
git-fetch-with-cli = truecargo add my-clients@0.1.0 --registry forgejoAbout this package
Generated clients for external service contracts
my-clients
Generated Rust clients for external service contracts.
Generated Clients
Each client has its contract, generator configuration, and generated source in
src/<service>/:
src/<service>/
├── contract.json
├── openapi-to-rust.toml
├── update-contract.sh (optional)
├── mod.rs
├── client.rs
└── types.rs
Forgejo
use my_clients::forgejo::client::HttpClient;
let client = HttpClient::new()
.with_base_url("https://code.martials.no/api/v1")
.with_api_key("token");
The Forgejo client is generated from src/forgejo/contract.json.
Regenerate it after updating the contract with:
./src/forgejo/update-contract.sh
just my_clients::generate forgejo
Install the generator once if necessary:
cargo install --locked openapi-to-rust --version 0.12.1
To add another client, add a directory such as src/example/ containing its
contract and openapi-to-rust.toml, then run just my_clients::generate example.
Dependencies
| ID | Version |
|---|---|
| bytes | ^1 |
| chrono | ^0.4 |
| reqwest | ^0.13 |
| reqwest-middleware | ^0.5 |
| serde | ^1 |
| serde_json | ^1 |
| thiserror | ^2 |
| url | ^2 |
| uuid | ^1 |
| tokio | ^1 |