You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`clickhouse_cloud_openapi.json`| Checked-in copy of the spec (used by tests) |
15
-
|`tests/spec_coverage_test.rs`| Validates client methods, model types, and field optionality match the spec |
15
+
|`tests/spec_coverage_test.rs`| Thin snapshot/live-spec consumer of the shared drift analyzer |
16
+
|`../clickhouse-openapi-analyzer`| Canonical Rust/OpenAPI parsing, comparison, report, and exemptions |
16
17
17
18
### Field optionality
18
19
19
20
The OpenAPI spec uses two conventions for marking fields required vs optional:
20
21
21
22
-**Schemas with a `required` array** (newer/beta endpoints) use standard OpenAPI semantics.
22
23
-**Schemas without `required`** (GA/legacy endpoints) treat fields whose description starts with `"Optional"` as optional. Everything else is implicitly required.
24
+
-**Known partial `required` arrays** use the union of that array and the description heuristic, as configured by the analyzer.
# Regenerate the DEPRECATED_FIELDS constant from the snapshot
42
44
python3 scripts/regenerate-deprecated-fields.py
43
45
46
+
# Regenerate the BETA_OPERATIONS constant from the snapshot
47
+
python3 scripts/regenerate-beta-lists.py
48
+
44
49
# Check for drift between the live spec and the library (dry run)
45
50
python3 scripts/check-openapi-drift.py --dry-run
46
51
```
@@ -51,9 +56,10 @@ Field optionality is maintained by hand — edit `models.rs` directly when the d
51
56
52
57
```bash
53
58
cargo test -p clickhouse-cloud-api # all tests
54
-
cargo test --test spec_coverage_test # spec coverage + field optionality only
55
-
cargo test --test client_test # wiremock-based client tests
56
-
cargo test --test models_test # serde round-trip tests
59
+
cargo test -p clickhouse-openapi-analyzer # analyzer fixtures + executable parity
60
+
cargo test -p clickhouse-cloud-api --test spec_coverage_test # shared snapshot report
61
+
cargo test -p clickhouse-cloud-api --test client_test # wiremock client tests
62
+
cargo test -p clickhouse-cloud-api --test models_test # serde round trips
57
63
```
58
64
59
65
Live-API lifecycle suites are `#[ignore]`d by default (they provision real resources):
@@ -79,17 +85,24 @@ cargo test --test clickpipe_smoke_test -- --ignored --nocapture # creat
79
85
80
86
All require `CLICKHOUSE_CLOUD_API_KEY`, `CLICKHOUSE_CLOUD_API_SECRET`, `CLICKHOUSE_CLOUD_TEST_ORG_ID`, `CLICKHOUSE_CLOUD_TEST_PROVIDER`, and `CLICKHOUSE_CLOUD_TEST_REGION` in the environment, and are wired into the scheduled `Cloud Integration` GitHub Actions workflow. The ClickPipes E2E suites additionally need AWS credentials and an `eu-west-1` region quota; `clickpipe_smoke_test` reads a pre-provisioned service ID from `CLICKHOUSE_CLOUD_TEST_CLICKPIPE_SERVICE_ID`.
81
87
82
-
The `spec_coverage_test` suite checks three things against the checked-in spec:
83
-
84
-
1. Every OpenAPI operation has a matching `pub async fn` in `client.rs`
85
-
2. Every OpenAPI schema has a matching `pub struct`/`pub enum` in `models.rs`
86
-
3. Every field's `Option<T>` vs `T` matches the spec's required/optional semantics
87
-
4.`DEPRECATED_FIELDS` matches the spec's `deprecated: true` fields (request- and response-side), and each one carries the `#[cfg(feature = "deprecated-fields")]` marker in `models.rs`
88
-
89
-
There are also `#[ignore]`d variants that run the same checks against the live spec.
88
+
`spec_coverage_test` sends the checked-in sources and snapshot through the
89
+
private `clickhouse-openapi-analyzer` crate. That same analyzer powers the
90
+
scheduled live-spec issue, so operation, model, field, optionality, beta,
91
+
deprecation, enum, snapshot, and stale-exemption findings share one
92
+
implementation. The single ignored test runs the same report against the live
93
+
spec.
90
94
91
95
### Optionality exemptions
92
96
93
-
Occasionally the spec marks a field as required but the API actually treats it as optional (e.g. sending an empty string triggers a `400 BAD_REQUEST`). In these cases we override the field to `Option<T>` in `models.rs` and add the field to the `OPTIONALITY_EXEMPTIONS` list in `spec_coverage_test.rs`.
94
-
95
-
The test prints a `NOTE:` line for every exemption that fires, and **fails** if an exemption becomes stale (i.e. the spec was corrected upstream and the override is no longer needed). To add a new exemption, add a `("RustStructName", "specFieldName")` entry to the constant with a comment explaining why.
97
+
Occasionally the spec cannot be followed literally because verified API
98
+
behavior differs. All such policy lives in
99
+
`crates/clickhouse-openapi-analyzer/src/config.rs`, including optionality,
0 commit comments