Skip to content

Commit fe95218

Browse files
Merge pull request #377 from joshrotenberg/feat/api-coverage-medium-priority-375
feat: Medium Priority API Coverage Improvements (Issue #375)
2 parents 45b184c + 0850e31 commit fe95218

File tree

4 files changed

+16126
-5
lines changed

4 files changed

+16126
-5
lines changed

CLAUDE.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,52 @@ let vpc = handler.create_active_active(subscription_id, region_id, &request).awa
465465
- **Testing**: Mock all HTTP calls with `wiremock`, never make real API calls in tests
466466
- **Active-Active**: Use `_active_active` suffixed functions for CRDB operations
467467
468+
## OpenAPI Specification Validation
469+
470+
### Automated Validation Tests
471+
The `redis-cloud` crate includes automated tests that validate our implementation against the official OpenAPI specification:
472+
473+
**Test File**: `crates/redis-cloud/tests/openapi_validation.rs`
474+
475+
**What is Validated**:
476+
1. **Spec Integrity** - OpenAPI spec loads and has required sections
477+
2. **Endpoint Count** - Verify we have the expected number of endpoints
478+
3. **Schema Definitions** - Key response types exist in spec
479+
4. **Endpoint Categories** - All expected API categories are present
480+
5. **Response Type Coverage** - Core fields match spec definitions
481+
482+
**Running Validation**:
483+
```bash
484+
cargo test --package redis-cloud --test openapi_validation
485+
```
486+
487+
### OpenAPI Spec Location
488+
- **Local Copy**: `crates/redis-cloud/tests/fixtures/cloud_openapi.json`
489+
- **Official Source**: https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json
490+
491+
### API Documentation Pattern
492+
All handler functions include OpenAPI references in their documentation:
493+
494+
```rust
495+
/// Get cloud accounts
496+
///
497+
/// Gets a list of all configured cloud accounts.
498+
///
499+
/// # API Endpoint
500+
///
501+
/// `GET /cloud-accounts`
502+
///
503+
/// See [OpenAPI Spec](https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json) - `getCloudAccounts`
504+
pub async fn get_cloud_accounts(&self) -> Result<CloudAccounts> {
505+
// ...
506+
}
507+
```
508+
509+
This pattern:
510+
- Links to the official OpenAPI specification
511+
- References the specific operationId from the spec
512+
- Makes it easy to cross-reference implementation with API docs
513+
468514
## Testing Approach
469515
470516
### MANDATORY Testing Requirements

crates/redis-cloud/src/cloud_accounts.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
//! - **Provider Details**: Retrieve provider-specific account information
2525
//! - **Multi-cloud Support**: Manage accounts across different cloud providers
2626
//!
27+
//! # API Reference
28+
//!
29+
//! All operations in this module map to the Redis Cloud REST API's Cloud Accounts endpoints.
30+
//! For detailed API documentation, see the [Redis Cloud OpenAPI Specification].
31+
//!
32+
//! [Redis Cloud OpenAPI Specification]: https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json
33+
//!
2734
//! # Example Usage
2835
//!
2936
//! ```no_run
@@ -281,17 +288,27 @@ impl CloudAccountsHandler {
281288
}
282289

283290
/// Get cloud accounts
291+
///
284292
/// Gets a list of all configured cloud accounts.
285293
///
286-
/// GET /cloud-accounts
294+
/// # API Endpoint
295+
///
296+
/// `GET /cloud-accounts`
297+
///
298+
/// See [OpenAPI Spec](https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json) - `getCloudAccounts`
287299
pub async fn get_cloud_accounts(&self) -> Result<CloudAccounts> {
288300
self.client.get("/cloud-accounts").await
289301
}
290302

291303
/// Create cloud account
304+
///
292305
/// Creates a cloud account.
293306
///
294-
/// POST /cloud-accounts
307+
/// # API Endpoint
308+
///
309+
/// `POST /cloud-accounts`
310+
///
311+
/// See [OpenAPI Spec](https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json) - `createCloudAccount`
295312
pub async fn create_cloud_account(
296313
&self,
297314
request: &CloudAccountCreateRequest,
@@ -300,9 +317,14 @@ impl CloudAccountsHandler {
300317
}
301318

302319
/// Delete cloud account
320+
///
303321
/// Deletes a cloud account.
304322
///
305-
/// DELETE /cloud-accounts/{cloudAccountId}
323+
/// # API Endpoint
324+
///
325+
/// `DELETE /cloud-accounts/{cloudAccountId}`
326+
///
327+
/// See [OpenAPI Spec](https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json) - `deleteCloudAccount`
306328
pub async fn delete_cloud_account(&self, cloud_account_id: i32) -> Result<TaskStateUpdate> {
307329
let response = self
308330
.client
@@ -312,19 +334,29 @@ impl CloudAccountsHandler {
312334
}
313335

314336
/// Get a single cloud account
337+
///
315338
/// Gets details on a single cloud account.
316339
///
317-
/// GET /cloud-accounts/{cloudAccountId}
340+
/// # API Endpoint
341+
///
342+
/// `GET /cloud-accounts/{cloudAccountId}`
343+
///
344+
/// See [OpenAPI Spec](https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json) - `getCloudAccountById`
318345
pub async fn get_cloud_account_by_id(&self, cloud_account_id: i32) -> Result<CloudAccount> {
319346
self.client
320347
.get(&format!("/cloud-accounts/{}", cloud_account_id))
321348
.await
322349
}
323350

324351
/// Update cloud account
352+
///
325353
/// Updates cloud account details.
326354
///
327-
/// PUT /cloud-accounts/{cloudAccountId}
355+
/// # API Endpoint
356+
///
357+
/// `PUT /cloud-accounts/{cloudAccountId}`
358+
///
359+
/// See [OpenAPI Spec](https://redis.io/docs/latest/operate/rc/api/api-reference/openapi.json) - `updateCloudAccount`
328360
pub async fn update_cloud_account(
329361
&self,
330362
cloud_account_id: i32,

0 commit comments

Comments
 (0)