This is the OpenAPI Generic SDK - a language-agnostic reference implementation (pseudocode + Rust reference) for building OpenAPI client libraries. It is NOT a functional SDK itself but a blueprint for implementing SDKs in specific languages.
- Author: Michael Cuffaro (@maiku1008)
- Maintainer: Francesco Bianco
- License: MIT
- Version: 1.0.0 (SDK_VERSION in Makefile)
openapi-generic-sdk/
├── src/ # Pseudocode specifications
│ ├── oauth_client.pseudo # OauthClient class spec
│ ├── api_client.pseudo # ApiClient class spec
│ └── types.pseudo # Type definitions, structs, enums, constants
├── tests/ # Pseudocode test specifications
│ ├── oauth_client_tests.pseudo
│ └── api_client_tests.pseudo
├── examples/ # Pseudocode usage examples
│ ├── token_generation.pseudo
│ └── api_calls.pseudo
├── docs/
│ └── implementation-guide.md # Detailed implementation guide with language examples
├── reference/ # Rust reference implementation (crate: openapi-sdk)
│ ├── Cargo.toml
│ ├── src/lib.rs # Full Rust implementation
│ ├── examples/ # Rust examples
│ └── docs/ # Rust-specific docs (contributing, code-of-conduct, crates-io)
├── Makefile # Build/release commands
└── README.md
Three core components:
- Basic Auth (base64-encoded
username:api_key) - Methods:
get_scopes,create_token,get_tokens,delete_token,get_counters - Endpoints:
/scopes,/token,/token/{id},/counters/{period}/{date}
- Bearer token auth
- Generic
request(method, url, payload?, params?)method - Convenience methods:
get,post,put,delete - Supports all HTTP methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
- Structs:
TokenResponse,ScopeInfo,CounterInfo,APIErrorResponse,SDKConfig,Credentials,HTTPResponse,RequestConfig - Enums:
Environment(PRODUCTION, TEST),HTTPMethod - Error classes:
HTTPError,ValueError
| Method | Endpoint | Description |
|---|---|---|
| GET | /scopes |
List available scopes |
| POST | /token |
Create access token |
| GET | /token |
List existing tokens |
| DELETE | /token/{id} |
Delete a token |
| GET | /counters/{period}/{date} |
Get usage statistics |
- Production:
https://oauth.openapi.it - Test:
https://test.oauth.openapi.it
make dev-push- Add, commit (prompts for message), pushmake dev-version- Show version from Cargo.tomlmake publish- Commit and push releasemake release- Commit, tag with SDK_VERSION, force-push tags
- Crate name:
openapi-sdk - Async runtime: Tokio
- HTTP client: reqwest (with blocking + json features)
- Serialization: serde + serde_json
- Auth encoding: base64
- Tests:
cargo test(unit tests in lib.rs) - Examples:
cargo run --example token_generation,cargo run --example api_calls
- Auth: Basic auth for OAuth, Bearer for API calls
- HTTP: JSON serialization/deserialization, query parameter handling
- Errors: Distinguish 4xx (client) vs 5xx (server), include status code + body
- Config: Support test/production environments, configurable timeouts/retries
- Env vars:
OPENAPI_USERNAME,OPENAPI_API_KEY,OPENAPI_ACCESS_TOKEN,OPENAPI_TEST_MODE,OPENAPI_BASE_URL - Defaults: Timeout 30s, connection timeout 10s, max retries 3, retry delay 1s
- Unit tests: Mock HTTP responses, test all methods, validate error handling
- Integration tests: Real API calls against test environment
- Test data: Standardized mock responses defined in test pseudocode files
- Coverage target: >90%
- Pseudocode files use
.pseudoextension - The
.gitignoreincludesreference/(Rust reference is a separate subproject) - The root
.gitignoreis Laravel-flavored (historical) - Each language SDK should follow its own naming conventions while preserving the API surface