Skip to content

feat: expand corpus protocol and multipart coverage - #49

Merged
lightsofapollo merged 2 commits into
mainfrom
fix/expanded-corpus-followup
Jul 29, 2026
Merged

feat: expand corpus protocol and multipart coverage#49
lightsofapollo merged 2 commits into
mainfrom
fix/expanded-corpus-followup

Conversation

@lightsofapollo

Copy link
Copy Markdown
Contributor

Summary

Expands the real-spec corpus follow-up with bounded, contract-driven support for several wire patterns that previously prevented generated clients and Axum servers from compiling or interoperating:

  • symmetric AWS query-protocol serialization and reconstruction, explicitly gated by info.x-providerName: amazonaws.com;
  • typed multipart request models on generated clients and servers, preserving exact binary bytes;
  • multipart request-size limits and normal generated JSON Schema validation;
  • OpenAPI simple/non-exploded array headers used by S3;
  • narrow embedded path-parameter affixes such as {api}.json, with canonical Axum route-collision rejection.

Protocol and safety details

AWS query conventions

  • Keeps OpenAPI wire names separate from Rust-safe identifiers.
  • Uses one-based numeric indexes and BTreeMap<usize, _> reconstruction.
  • Preserves present-empty nested arrays, objects, and indexed object entries.
  • Keeps client serialization and server reconstruction driven by matching bounded metadata.
  • Rejects excessive nesting, ambiguous wire namespaces, unsupported additionalProperties, and duplicate/conflicting representations instead of guessing.
  • Does not apply AWS outer-prefix conventions to ordinary OpenAPI form+explode objects.

Multipart

  • Generated clients accept generated request-body models and construct reqwest::multipart::Form internally.
  • Generated Axum servers extract supported bounded object schemas into the same generated models.
  • Preserves raw binary bytes for BinaryStrategy::Bytes and BinaryStrategy::VecU8; supports textual BinaryStrategy::String symmetrically.
  • Supports signed and unsigned scalar parsing, including uint64 above i64::MAX.
  • Runs the normal generated request-body JSON Schema validator after reconstruction.
  • Applies server.validation.max_body_bytes with Axum DefaultBodyLimit.
  • Avoids per-byte serde_json::Value expansion: binary payloads stay in dedicated byte slots and are restored into the typed model after validation.
  • Rejects duplicate, unknown, missing, malformed, unresolved, cyclic, array/object, and open additionalProperties multipart shapes deterministically.
  • Emits Axum's multipart feature only when required.
  • Covers validation-disabled generation, all public binary strategies, and embedded-affix paths with exact generated dependency-fragment compilation.

Headers and routes

  • Emits S3-style simple arrays as one comma-separated header and reconstructs typed values server-side.
  • Preserves referenced header-item models during pruning.
  • Supports one parameter plus literal affixes within a path segment.
  • Canonicalizes dynamic capture names when checking method/route collisions, so {id} and {name} cannot evade collision detection.

Corpus and real-spec verification

The rebuilt generator was run across all 241 corpus entries:

  • 226/241 fully successful;
  • client generation and operation listing succeeded for all 241;
  • 15 server-generation failures are intentional bounded rejections rather than inferred/unsafe support.

Real-spec spot checks covered Adobe AEM, api.video, Amazon DocumentDB, Amazon S3, and apis.guru.

MinIO smoke test

A regenerated S3 client successfully completed:

  • ListBuckets
  • CreateBucket
  • PutObject
  • GetObject
  • exact upload/download payload equality
  • cleanup

Verification

  • cargo test --all-features
  • cargo fmt --all -- --check
  • cargo clippy --all-features -- -D warnings
  • RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features
  • CONFORMANCE_REPORT=1 cargo test --test conformance --test conformance_json_schema
  • conformance reports unchanged
  • cargo build --quiet --bin openapi-to-rust
  • generated multipart client/server runtime round trip
  • generated AWS query client/server runtime round trip
  • exact-dependency generated compilation for all multipart binary strategies with validation disabled and an embedded-affix path
  • full 241-spec corpus probe
  • repeated MinIO S3 smoke test with exact payload equality
  • independent security/logic review, including remediation and clean re-review of the final linkage regression

cargo clippy --all-targets --all-features -- -D warnings remains affected by established test/example unwrap/expect lint failures; the CI-equivalent library/all-feature clippy command above is clean.

Review notes

The query and multipart implementations are intentionally bounded. This PR rejects shapes for which client/server symmetry, extraction closure, validation semantics, or memory behavior cannot be guaranteed. Please review those generation-time rejection boundaries as part of the API contract.

Draft for human review; no auto-merge.

Add bounded AWS query conventions, typed multipart client/server generation, simple array headers, and embedded path affixes. Enforce validation, size limits, route collision checks, and deterministic rejection of unsupported wire shapes.
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openapi-to-rust Ready Ready Preview, Comment Jul 29, 2026 5:48am

Request Review

@lightsofapollo
lightsofapollo marked this pull request as ready for review July 29, 2026 14:20
@lightsofapollo
lightsofapollo merged commit f3dac41 into main Jul 29, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant