Class Oas31CompositionLowering


  • public final class Oas31CompositionLowering
    extends Object
    Ordered composition lowering for the cpp-boost-beast client: builds the per-schema Oas31CompositionLowering.CompositionDescriptors (branch scan surfaces, validator ids, null capability, discriminator) before model processing, computes recursive allOf intersections into synthetic schemas, and lowers composed branch sets to C++ storage types (std::optional / std::variant / CompositionBranchValue / boost::json::value) per the ordered rules.

    The descriptor records (Oas31CompositionLowering.CompositionDescriptor and friends) are public nested types so tests and template-facing maps keep using the same accessor surface. The class is deliberately stateless: every method takes its inputs as parameters, incl. the parsed openAPI document and the component-schema index; the codegen keeps the compositionDescriptors / allOfIntersections indexes and the model-phase consumers (processComposedModelFromDescriptor, fromModel, template maps) — those mutate CodegenModel state and stay on the generator.

    Branch surfaces are scanned by Oas31SchemaSurfaceAssertionScanner.scanSurfaceAssertions(io.swagger.v3.oas.models.media.Schema, io.swagger.v3.oas.models.OpenAPI, java.util.List<java.lang.String>, java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.lang.Object>, boolean); exceptions (UnsupportedSchemaAssertionException, AllOfRequiredUnsatisfiableException) live on the generator and are referenced through it.

    • Method Detail

      • buildDiscriminatorBranchIndex

        public static List<Map<String,​Object>> buildDiscriminatorBranchIndex​(Set<CodegenDiscriminator.MappedModel> mappedModels,
                                                                                   List<Oas31CompositionLowering.CompositionBranchDescriptor> branches)
        Builds a list of {key, value} maps from the full set of discriminator mapped models (explicit URI mappings + implicit component-name mappings) for template-iteration. Each entry maps a C++-escaped discriminator value to a composition branch index so the template can reorder candidate validation for diagnostics.

        Unresolvable mappings (where the model name does not match any branch resolved schema name) fail generation with a clear diagnostic per §8.

        Parameters:
        mappedModels - the full set of discriminator mapped models
        branches - the composition branch descriptors
        Returns:
        list of {key, value} maps; non-empty when at least one mapping resolves to a valid branch
        Throws:
        RuntimeException - when a mapping does not resolve to any branch
      • buildDiscriminatorBranchIndex

        public static List<Map<String,​Object>> buildDiscriminatorBranchIndex​(Map<String,​String> discMapping,
                                                                                   List<Oas31CompositionLowering.CompositionBranchDescriptor> branches)
        Fallback variant: builds a list of {key, value} maps from explicit discriminator mapping entries only (used when the codegen model's full MappedModel set is unavailable).
        Parameters:
        discMapping - the discriminator.value → target mapping
        branches - the composition branch descriptors
        Returns:
        list of {key, value} maps