Roctogen: a rust client library for the GitHub v3 API
This client API is generated from the upstream OpenAPI specification. The library currently supports webassembly and synchronous requests with the Isahc HTTP client.
Install
Add the following to your Cargo.toml file
[dependencies]
roctogen = "0.1.0"
API
Documentation
Usage
A quick example of this library:
use ;
use Auth;
let auth = None;
let per_page = new;
let mut params: ReposListCommitsParams = per_page.as_ref.into;
params = params.author.page;
new.list_commits;
Async
All the async methods are suffixed with _async (currently only supported on the wasm
target).
Webassembly
To compile for webassembly, you can use wasm-pack or compile with the
wasm32-unknown-unknown target:
$ wasm-pack build
$ cargo build --target wasm32-unknown-unknown
If you are building a cloudflare worker, you would use the
wrangler wrapper:
$ wrangler preview --watch
Isahc
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:
$ cargo build --features isahc
GitHub preview features
GitHub supports a phased rollout of non-stable endpoints behind header flags. These are supported in this library through cargo feature flags.
$ cargo build --features squirrel-girl
Generate the API
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).
$ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources
Tests
Beware, tests are currently still doing real HTTP requests to the GitHub API.
Run the wasm tests:
$ wasm-pack test --firefox --headless
Run the sync tests:
$ cargo test --features isahc,mercy,squirrel-girl,inertia,starfox --target x86_64-unknown-linux-gnu -- --nocapture
License: Apache-2.0