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
fix(generator): make 20 real-world specs compile, gate CI on the working set
Running scripts/spec-compile.sh against all 54 OpenAPI 3.x specs in the
repo (gitea is Swagger 2.0, skipped) surfaced six classes of generator
bugs. Fixed the ones that move the most specs from FAIL → PASS:
1. `r#self` panic
`self`, `super`, `crate`, `Self` cannot be raw identifiers in Rust —
proc_macro2 panics outright. Spec fields named `self` (datadog-v2,
github, microsoft-graph, snyk, …) hit this. Fix: rename to
`<keyword>_field` / `<keyword>_param` instead of `r#<keyword>`.
2. operationId collisions reject whole documents
T6's strict-error policy was correct per spec but real-world docs
(arcade, cal-com, telnyx, val-town, …) often violate it. Fix:
auto-disambiguate by suffixing with HTTP method (`opId_post`,
`opId_put`), and a counter on further collisions, with a stderr
warning. Spec validity is recoverable; whole-document rejection is not.
3. Extensions reject non-`x-*` keys
Real specs sprinkle non-`x-` fields in places they don't belong
(`produces`/`in`/`type`/`density`/`title`/`description` were observed).
Fix: Extensions now accepts any leftover key but exposes
`non_extension_keys()` so silent drops remain visible — the CLI can
warn instead of erroring.
4. exclusiveMinimum: bool vs number
3.0/Swagger used `bool`; 3.1 (JSON Schema 2020-12) uses `number`.
Fix: model as a `bool | f64` enum.
5. `Vec<serde_json::Value>` Ident panic
generate_array_item_type split on "::" but produced strings with
angle brackets that aren't valid idents. Fix: parse via
`syn::parse_str::<syn::Type>` first.
6. enum variant collisions on signed numbers
`1` and `-1` both produced `Variant1`. Fix: prefix negatives with
`Neg` (e.g. `VariantNeg1`).
7. Twilio-style filter param ident collisions
`StartTime`, `StartTime<`, `StartTime>` all snake-cased to
`start_time`. Fix: map `<`, `>`, `<=`, `>=` to `_lt`/`_gt`/`_lte`/
`_gte` in sanitize_param_name. Twilio went from CHECK-FAIL to PASS.
8. Version gate didn't run in TOML config flow
The `generate` subcommand in src/bin/openapi-to-rust.rs has its own
pipeline that bypasses cli::run_generation_cli. Mirrored the version
check so Swagger 2.0 specs (gitea) error early with a clear hint
instead of failing later inside the deserializer.
scripts/spec-compile.sh
- Auto-discovers specs/*.{yaml,json}.
- Skips Swagger 2.0 with a SKIP marker (gitea).
- Optional SPEC_COMPILE_PARSE_ONLY=1 for quick generator-only checks.
- Optional SPEC_COMPILE_LIMIT=N / positional whitelist of names.
ci(spec-compile)
The job now compiles a "gold list" of 20 specs that pass cleanly:
anthropic, asana, browserbase, cartesia, cerebras, coda, coingecko,
digitalocean, groq, imagekit, launchdarkly, meta-llama, openai, resend,
runway, spotify, terminal-shop, twilio, val-town, writer. Local
`scripts/spec-compile.sh` (no args) still runs the full corpus. The
remaining 34 specs surface other generator bugs (E0308 type mismatches,
E0428 name collisions in github, E0117 orphan rule violations in
stripe, E0072 recursive type sizing in snyk) — tracked in #14 as
follow-ups.
All 205 unit tests still pass; clippy + fmt clean.
Refs #14
0 commit comments