feat(cpp-boost-beast-client): variant-first oneOf/anyOf/allOf composition

Draft
BO
3mo ago
+11800-195

Description

Breaking redesign of composed-schema support in cpp-boost-beast-client.

Previously, oneOf / anyOf / allOf models were emitted as empty object shells, so request/response JSON lost real values (e.g. {"model":{},"input":{}}). This PR lowers composed OpenAPI schemas to standard C++ types and generates working encode/decode.

Composition lowering (OAS-first):

  • oneOf / non-null anyOf → std::variant<...>
  • anyOf: [T, null] / nullable → std::optional<T>
  • anyOf string + string-enum → std::string (anyOf-only collapse)
  • oneOf string + string-enum → boost::json::value (no false exclusive collapse)
  • Compatible allOf object merge; hard error on scalar conflicts
  • Discriminator-aware decode for object unions
  • OAS const / single-value enum fixed-on-encode (x-stainless-const optional only)

API / transport:

  • JSON bodies/responses use generated converters
  • Multi-content / SSE driven by response content map + Accept (not vendor stream flags)
  • Multipart binary|object variant parts

Motivation and Context

Composed schemas are common in modern OpenAPI documents. Empty-shell output made the Beast client unusable for those APIs. This is intentionally breaking for cpp-boost-beast-client only; no other generators are affected.

Testing

  • Unit tests: CppBoostBeastClientCodegenTest, CppBoostBeastClientApiCodegenTest
  • OAS composition fixtures under src/test/resources/3_1/cpp-boost-beast-client/ (+ oas-compliance/)
./mvnw -pl modules/openapi-generator -am \
  -Dtest=CppBoostBeastClientCodegenTest,CppBoostBeastClientApiCodegenTest \
  -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false test

Breaking change

Yes — generated model/API surface for composed schemas changes from empty structs to std::variant / std::optional / collapsed types. Prior composed output was non-functional.

Related issues

N/A

PR checklist

  • Read the contribution guidelines
  • Pull Request title clearly describes the work in the base branch and your test/feature branch
  • If this PR adds or updates a feature, did you update the documentation / samples?
  • If this PR adds or updates a feature, did you update the tests?

Summary by cubic

Implements variant-first oneOf/anyOf/allOf in cpp-boost-beast-client with real C++ types, working JSON encode/decode, multi-content + SSE streaming, and a C++17 upgrade. Adds a Gate A composition compliance harness and updates docs (feature support table, include mappings, and CMake/OpenSSL minimums).

  • Bug Fixes

    • Decoding: enforce oneOf exactly-one for request/response, refresh discriminator resolution after alias collapse, enforce const-property invariants, validate int32 bounds, and add std::map/std::uint8_t branches for composed variants.
    • Nullability: $ref, arrays, maps, and inline object schemas marked nullable now lower to std::optional<T>; fix regressions for inherited nullable properties (allOf + discriminator) by using correct optional storage and has_value/reset paths.
    • Streaming: executeStream delivers framed SSE events incrementally, rejects schema-less SSE, and only generates dual-content stream methods when an SSE element type is resolved.
    • Converters: ensure variant/optional helpers are declared before container templates so nested containers of composed types use the correct overloads.
    • Compliance/docs: restore gate-a.sh composition harness; fix README converter function names; align README minimums with CMake 3.14 and OpenSSL 1.1.0; update generator docs to mark composed-schema features as supported and document std::variant/std::optional/std::monostate includes.
  • Migration

    • Breaking: composed-schema models are now std::variant/std::optional/collapsed aliases. Update call sites to construct/visit variants and check optionals.
    • Requires C++17 (CXX_STANDARD 17).
    • Streaming: use HttpClient::executeStream. For multi-content/SSE, set an Accept header; stream methods return std::vector<element> and use generated fromJsonValue_{Type}. SSE endpoints must define a response schema.