This client API is generated from the upstream OpenAPI specification. The library currently supports webassembly and synchronous requests with the Isahc HTTP client.
Add the following to your Cargo.toml
file
nocompile
[dependencies]
roctogen = "0.1.0"
A quick example of this library:
```rust use roctogen::api::{self, repos}; use roctogen::auth::Auth;
let auth = Auth::None; let per_page = api::PerPage::new(10);
let mut params: repos::ReposListCommitsParams = perpage.asref().into(); params = params.author("fussybeaver").page(2);
repos::new(&auth).list_commits("fussybeaver", "bollard", Some(params)); ```
All the async
methods are suffixed with _async
(currently only supported on the wasm
target).
To compile for webassembly, you can use wasm-pack
or compile with the
wasm32-unknown-unknown
target:
nocompile
$ wasm-pack build
nocompile
$ cargo build --target wasm32-unknown-unknown
If you are building a cloudflare worker, you would use the
wrangler
wrapper:
nocompile
$ wrangler preview --watch
Building on non-wasm
targets generally requires adopting a feature for the desired
client adapter. This library only supports isahc
at the
moment, but other adapters are planned, and contributions are welcome.
Compiling for the isahc
client required the isahc
feature:
nocompile
$ cargo build --features isahc
GitHub supports a phased rollout of non-stable endpoints behind header flags. These are supported in this library through cargo feature flags.
nocompile
$ cargo build --features squirrel-girl
The majority of code is generated through the Swagger OpenAPI
generator (version 3). Building requires the
mvn
Java build tool, pegged at Java version 8 (so
you'll need an appropriate JDK).
nocompile
$ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources
Beware, tests are currently still doing real HTTP requests to the GitHub API.
Run the wasm tests:
nocompile
$ wasm-pack test --firefox --headless
Run the sync tests:
nocompile
$ cargo test --features isahc,mercy,squirrel-girl,inertia,starfox --target x86_64-unknown-linux-gnu -- --nocapture
License: Apache-2.0