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 generated Anthropic + OpenAPI clients compile
Regenerating the clients for the Anthropic and OpenAI specs against the
post-conformance generator surfaced four codegen bugs introduced by the
recent batch:
1. Optional request bodies (T11) were chained as
`req.post(url).multipart(form)` even when `form: Option<Form>`. The
chain doesn't typecheck for optional bodies.
Fix: generate_request_body now emits statements that mutate `req`,
wrapped in `if let Some(...)` for optional bodies.
2. $ref-typed parameters (T10) emitted `(StructType).to_string()` for
non-enum schema refs (e.g. `Metadata` — a wrapper struct). Structs
don't implement Display.
Fix: at analysis time, only keep schema_ref on a parameter when the
referenced component is a string-with-enum/const. Struct refs fall
back to `String` until proper deepObject/form serialization (T14).
3. The previous fix exposed a second issue: enum-typed query params
called `.as_ref()` on the enum value, but generated string enums
didn't implement AsRef<str> or Display.
Fix: generate_string_enum now emits `as_str()`, `Display`, and
`AsRef<str>` impls so the enum's serde-renamed wire form drops
straight into headers, query strings, and path segments.
4. Query/path/header emitters used `param.rust_type == "String"` to
decide whether to call `.as_ref()` before `.to_string()`. After T10,
that's wrong for enum-typed params (rust_type stays "String" but
schema_ref carries the enum name).
Fix: param_uses_as_ref_str() helper consults schema_ref too.
Verified via the new scripts/spec-compile.sh: regenerates clients for
specs/anthropic.yaml and specs/openai.yaml and runs `cargo check` on
both — both compile cleanly.
ci(spec-compile): run scripts/spec-compile.sh in a new CI job
Regression guard: any generator change that emits invalid Rust against
the Anthropic or OpenAI specs fails the PR. Unit tests exercise the
generator surface but can pass while real-world specs break — this
catches that gap.
chore: ignore /tmp/{spec-compile,gen-*}/ build artifacts
Refs #14
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments