This is a rust API wrapper for https://spacetraders.io V2
Now generated by https://openapi-generator.tech/docs/generators/rust/
Includes patches for documentation missing from the main API docs
Use the following example to get started.
```rust use spacedust::apis::agentsapi::getmyagent; use spacedust::apis::configuration::Configuration; use spacedust::apis::defaultapi::register; use spacedust::models::register_request::{Faction, RegisterRequest};
async fn main() -> Result<(), Box
// Create Register Request
let reg_req = RegisterRequest::new(Faction::Cosmic, "<3-14 character string>".to_string());
// Register Agent
let register_response = register(&conf, Some(reg_req)).await;
match register_response {
Ok(res) => {
println!("{:#?}", res);
// Update Config with Agent Token
conf.bearer_access_token = Some(res.data.token);
}
Err(err_res) => {
panic!("{:#?}", err_res);
}
}
// Get Agent Details to Confirm Working
match get_my_agent(&conf).await {
Ok(res) => {
println!("{:#?}", res);
// Print Symbol
println!("My Symbol: {:#?}", res.data.symbol);
}
Err(err_res) => {
panic!("{:#?}", err_res);
}
}
Ok(())
} ```
FIRST update the docs fork with the spacedust patches. You can just 'Sync Fork' from the github web UI unless there are merge conflicts (there haven't been so far)
Clone the project, including --recurse-submodules:
bash
git clone --recurse-submodules git@github.com:brct-james/spacedustrs.git
Ensure submodules are initialized and updated:
bash
git submodule update --init --recursive --remote
Clean the output directory:
bash
sudo rm -rf client-dist
Remake the directory:
bash
mkdir client-dist
Update your local image of openapitools/openapi-generator-cli:latest-release
bash
docker pull openapitools/openapi-generator-cli:latest-release
Run the following command, which uses the openapi-generator-cli docker image to generate the client:
bash
docker run --rm \
-v ${PWD}:/local openapitools/openapi-generator-cli:latest-release generate \
-i /local/spacetraders-api-docs-spacedust-patch/reference/SpaceTraders.json \
-g rust \
-o /local/client-dist \
--additional-properties=packageName=spacedust,supportAsync=true,supportMiddleware=true
Copy the client-dist/src to src
bash
cp -r client-dist/src .
Notice: For the moment, manually check that the content-length middleware fixes (cargo.toml dependencies async-trait
and task-local-extensions
, lib.rs mod middleware
, src/middleware.rs, and src/apis/configuration.rs reqwest_middleware_builder
) are not being reverted. You will probably need to use at minimum the following:
bash
git checkout 34a74b36e341444a8dbe6ee979bb0163cbfe3bb9 src/apis/configuration.rs
git checkout 34a74b36e341444a8dbe6ee979bb0163cbfe3bb9 src/lib.rs
Todo: Create a better merge strategy - perhaps maintain the content-length-middleware branch and merge it into the local branch after generating a new client?
Update Cargo.toml with any new dependencies, update documentation, tick version, commit changes, and publish to cargo