feat(cpp-boost-beast-client): variant-first oneOf/anyOf/allOf composition
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-nullanyOf→std::variant<...>anyOf: [T, null]/ nullable →std::optional<T>anyOfstring + string-enum →std::string(anyOf-only collapse)oneOfstring + string-enum →boost::json::value(no false exclusive collapse)- Compatible
allOfobject merge; hard error on scalar conflicts - Discriminator-aware decode for object unions
- OAS
const/ single-valueenumfixed-on-encode (x-stainless-constoptional only)
API / transport:
- JSON bodies/responses use generated converters
- Multi-content / SSE driven by response
contentmap + Accept (not vendorstreamflags) - 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_tbranches for composed variants. - Nullability:
$ref, arrays, maps, and inline object schemas marked nullable now lower tostd::optional<T>; fix regressions for inherited nullable properties (allOf + discriminator) by using correct optional storage andhas_value/resetpaths. - Streaming:
executeStreamdelivers 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.shcomposition harness; fix README converter function names; align README minimums withCMake3.14 and OpenSSL 1.1.0; update generator docs to mark composed-schema features as supported and documentstd::variant/std::optional/std::monostateincludes.
- Decoding: enforce oneOf exactly-one for request/response, refresh discriminator resolution after alias collapse, enforce const-property invariants, validate int32 bounds, and add
-
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 returnstd::vector<element>and use generatedfromJsonValue_{Type}. SSE endpoints must define a response schema.
- Breaking: composed-schema models are now