A Rust client library for the Harbor API, automatically generated from their OpenAPI specification.
- Fully typed API client generated from Harbor's OpenAPI spec
- Async/await support with tokio
- Automatic retry and error handling via progenitor
- Builder pattern for constructing API requests
Add this to your Cargo.toml:
[dependencies]
harbor-api = { git = "https://github.com/AprilNEA/harbor-api" }use harbor_api::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client instance
let client = Client::new("https://api.harbor.gg");
// Make API calls using the generated methods
// Example (adjust based on actual API endpoints):
// let response = client.get_something().send().await?;
Ok(())
}This project uses a build script to generate the API client from Harbor's OpenAPI specification.
- Rust 1.70 or later
- Internet connection (for fetching the OpenAPI spec during build)
cargo buildYou can override the default API specification URL by setting the SPEC_URL environment variable:
SPEC_URL=https://your-harbor-instance.com/api/swagger.json cargo buildThe API client is generated at build time using progenitor. The build script:
- Fetches the OpenAPI specification from Harbor's API
- Ensures all operations have unique operation IDs
- Filters out unsupported operations (e.g., multipart/form-data)
- Generates type-safe Rust code
harbor-api/
├── Cargo.toml # Project dependencies
├── build.rs # Build script for code generation
├── src/
│ └── lib.rs # Library entry point (includes generated code)
└── target/
└── debug/
└── build/.../out/
└── codegen.rs # Generated API client code
- Operations that use
multipart/form-datacontent type are not supported and are filtered out during code generation - The generated client requires an active internet connection during the build process to fetch the API specification
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source. Please check the repository for license details.
- AprilNEA - GitHub
- Harbor for providing the API
- progenitor for the excellent OpenAPI code generation tools