Giter Site home page Giter Site logo

roctogen's Introduction

license docs GitHub workflow

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 both tokio and non-tokio based asynchronous requests and minimal dependency blocking synchronous requests with a choice of different clients, enabled through cargo features:

Install

Add the following to your Cargo.toml file

[dependencies]
roctogen = "0.12"

API

Documentation

API docs.

Endpoints.

Supported endpoints:

Usage

A quick example of this library:

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 = per_page.as_ref().into();
params = params.author("fussybeaver").page(2);

repos::new(&auth).list_commits("fussybeaver", "bollard", Some(params));

Async

All the async methods are suffixed with _async, and are available on the wasm target or isahc and reqwest adapters.

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

Client adapters

Building on non-wasm targets generally requires adopting a feature for the desired client adapter.

Isahc

Compiling for the isahc client required the isahc feature:

$ cargo build --features isahc

Reqwest

Compiling for the reqwest client required the reqwest feature:

$ cargo build --features reqwest

Ureq

Compiling for the ureq client required the ureq feature:

$ cargo build --features ureq

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 that are not run with the mock feature 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

In order to avoid GitHub's API rate limiting, you can run the non-wasm tests using wiremock. You'll need to start wiremock in the background:

$ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock
rodolpheche/wiremock

Regenerate the wiremock stubs

You should regenerate the stubs if the remote API has changed:

$ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock -u (id -u):(id -g) rodolpheche/wiremock --verbose --proxy-all="https://api.github.com" --record-mappings

License: Apache-2.0

roctogen's People

Contributors

fussybeaver avatar octokitbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

roctogen's Issues

Notify rest-api-description changes 89c295d8..a062d559

Notify rest-api-description changes 89c295d8..a062d559

Commits

Update OpenAPI Descriptions

Update OpenAPI Descriptions

Notify rest-api-description changes 2183e81a..6117e89b

Notify rest-api-description changes 2183e81a..6117e89b

Commits

Update OpenAPI Descriptions

Update OpenAPI Descriptions

Update OpenAPI Descriptions

Consider using a less specific wasm-bindgen version

Currently, roctogen uses wasm-bindgen "=0.2.72", which can cause conflicts with other crates. For example, trying to use iced and wasm-bindgen in the same project results in the following:

Cargo.toml:

[dependencies]
roctogen = { version="0.3", default_features = false, features=["ureq"] }

[dependencies.iced]
version = "0.3"
default_features = false
features = ["glow", "image", "tokio"]
❯ cargo build
    Updating crates.io index
error: failed to select a version for `wasm-bindgen`.
    ... required by package `wgpu v0.7.0`
    ... which is depended on by `iced_wgpu v0.4.0`
    ... which is depended on by `iced v0.3.0`
    ... which is depended on by `eslauncher2 v0.8.1 (/home/mco/Code/ESLauncher2)`
versions that meet the requirements `=0.2.69` are: 0.2.69

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.72`
    ... which is depended on by `roctogen v0.3.0`
    ... which is depended on by `eslauncher2 v0.8.1 (/home/mco/Code/ESLauncher2)`

failed to select a version for `wasm-bindgen` which could resolve this conflict

If at all possible, could you make this requirement less specific?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.