Class CppBoostBeastModelCodegen

    • Field Detail

      • tolerateNonNullableNulls

        protected boolean tolerateNonNullableNulls
        Compatibility mode for server responses that send undeclared nulls.
      • LOGGER

        protected final org.slf4j.Logger LOGGER
      • variantModels

        protected Set<String> variantModels
        Tracks model names resolved as oneOf/anyOf variant types for shared_ptr exclusion.
      • resolvedAliasTypes

        protected Map<String,​String> resolvedAliasTypes
        Caches resolved C++ types for composed models so postProcessModels can transitively resolve $ref chains through model aliases (for example, ModelIds referencing ModelIdsShared, both ultimately std::string).
      • composedKeywordsByModel

        protected Map<String,​String> composedKeywordsByModel
        Retains composition semantics after named schemas are lowered to C++ aliases.
      • compositionDescriptors

        protected Map<String,​Oas31CompositionLowering.CompositionDescriptor> compositionDescriptors
        Descriptor index mapping schema name to composition descriptor, populated in preprocessOpenAPI after inline model flattening. Replaces raw schema inspection as the semantic source for branch lowering.
      • sourceOpenApi

        protected io.swagger.v3.oas.models.OpenAPI sourceOpenApi
        OpenAPI document retained for operation and model post-processing.
      • hasExplicitRootServers

        protected boolean hasExplicitRootServers
        Whether the source document explicitly declares its root servers field.
      • webhookPreservation

        protected List<String> webhookPreservation
        Preserved inbound-only webhook metadata. Webhooks are removed from outbound API generation so upstream folding cannot replace path APIs.
      • operationCallbacks

        protected Map<String,​List<String>> operationCallbacks
        Callback and response-link names keyed by path and method.
      • formatAssertionPolicy

        protected String formatAssertionPolicy
        Policy for format metadata in composition branch matching. Formats remain annotations and never affect branch match counts.
      • FORMAT_ASSERTION_POLICY_ANNOTATION

        protected static final String FORMAT_ASSERTION_POLICY_ANNOTATION
        Value type for the formatAssertion option.
        See Also:
        Constant Field Values
      • validateOnDecode

        protected boolean validateOnDecode
        Controls composition-branch validation during model decoding.
      • preserveAdditionalProperties

        protected boolean preserveAdditionalProperties
        Retains undeclared JSON object members in generated object models.
      • componentSchemaIdsByName

        protected Map<String,​String> componentSchemaIdsByName
      • OAS_31_DIALECT

        public static final String OAS_31_DIALECT
        Pinned OAS 3.1 Schema dialect (spec.openapis.org/oas/3.1/dialect/2024-11-10).
        See Also:
        Constant Field Values
      • OAS_31_DIALECT_BASE_ALIAS

        public static final String OAS_31_DIALECT_BASE_ALIAS
        OAS alias accepted only as the identifier for the same pinned revision.
        See Also:
        Constant Field Values
      • DRAFT_2020_12

        public static final String DRAFT_2020_12
        Plain JSON Schema Draft 2020-12 core identifier (non-OAS dialect).
        See Also:
        Constant Field Values
    • Constructor Detail

      • CppBoostBeastModelCodegen

        protected CppBoostBeastModelCodegen()
    • Method Detail

      • getWebhookPreservation

        public List<String> getWebhookPreservation()
      • idOf

        protected static String idOf​(io.swagger.v3.oas.models.Operation op)
      • beginGeneration

        protected void beginGeneration​(io.swagger.v3.oas.models.OpenAPI openApi)
        Starts an isolated state set for one generator invocation.
      • detectExplicitRootServers

        protected boolean detectExplicitRootServers()
        swagger-parser materializes the implicit root server as /, which is indistinguishable from a source-level servers: [{url: /}] in the model. Consult the raw document before server-precedence assembly.
      • resolveEffectiveDialect

        public static CppBoostBeastModelCodegen.OasDialect resolveEffectiveDialect​(String jsonSchemaDialect,
                                                                                   String rootSchema)
        Dialect resolution, normative-structure checks, and the exhaustive keyword-occurrence scanner live in Oas31KeywordScanner; the delegates below keep this generator's public API stable for tests and templates.
      • resolveDocumentDialect

        public static CppBoostBeastModelCodegen.OasDialect resolveDocumentDialect​(io.swagger.v3.oas.models.OpenAPI openAPI)
        Resolve the effective dialect of an OpenAPI document from its declared knobs.
      • validateNormativeOas3Structure

        public List<String> validateNormativeOas3Structure​(io.swagger.v3.oas.models.OpenAPI openAPI)
        OAS 3 structural normative checks (see Oas31KeywordScanner).
      • validateDialectPolicy

        public List<String> validateDialectPolicy​(io.swagger.v3.oas.models.OpenAPI openAPI)
        Dialect/metaschema policy gate (see Oas31KeywordScanner).
      • failClosedKeywords

        public Set<String> failClosedKeywords​(io.swagger.v3.oas.models.OpenAPI openAPI)
        Set of fail-closed required-vocabulary keywords for this document.
      • addMustacheLambdas

        protected com.google.common.collect.ImmutableMap.Builder<String,​com.samskivert.mustache.Mustache.Lambda> addMustacheLambdas()
        Description copied from class: DefaultCodegen
        Preset map builder with commonly used Mustache lambdas. To extend the map, override addMustacheLambdas(), call parent method first and then add additional lambdas to the returned builder. If common lambdas are not desired, override addMustacheLambdas() method and return empty builder. Corresponding user documentation: docs/templating.md, section "Mustache Lambdas"
        Overrides:
        addMustacheLambdas in class AbstractCppCodegen
        Returns:
        preinitialized map with common lambdas
      • isSchemaValidationSupportingFile

        protected static boolean isSchemaValidationSupportingFile​(SupportingFile file)
      • fromModel

        public CodegenModel fromModel​(String name,
                                      io.swagger.v3.oas.models.media.Schema model)
        Description copied from class: DefaultCodegen
        Convert OAS Model object to Codegen Model object.
        Specified by:
        fromModel in interface CodegenConfig
        Overrides:
        fromModel in class DefaultCodegen
        Parameters:
        name - the name of the model
        model - OAS Model object
        Returns:
        Codegen Model object
      • fromParameter

        public CodegenParameter fromParameter​(io.swagger.v3.oas.models.parameters.Parameter parameter,
                                              Set<String> imports)
        Description copied from class: DefaultCodegen
        Convert OAS Parameter object to Codegen Parameter object
        Overrides:
        fromParameter in class DefaultCodegen
        Parameters:
        parameter - OAS parameter object
        imports - set of imports for library/package/module
        Returns:
        Codegen Parameter object
      • codegenParameterStyled

        protected void codegenParameterStyled​(io.swagger.v3.oas.models.parameters.Parameter parameter,
                                              CodegenParameter codegenParameter)
        Records the OAS 3.1 serialization facts consumed by the C++ wire layer. Style defaults to form for query/cookie and simple for path/header. Explode defaults to true only for form. allowReserved is surfaced consistently; allowEmptyValue applies only to form-style query parameters.
      • queryCollectionDelimiter

        protected String queryCollectionDelimiter​(io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style)
      • addContainerPropertyNames

        protected void addContainerPropertyNames​(List<CodegenProperty> properties)
      • reserveExtraJsonPropertyIdentifiers

        protected void reserveExtraJsonPropertyIdentifiers​(CodegenModel codegenModel)
      • lowerInlineComposedSchema

        protected String lowerInlineComposedSchema​(io.swagger.v3.oas.models.media.Schema p)
        Resolves an inline oneOf/anyOf schema to its lowered C++ type by computing branch types and applying the same ordered lowering rules as model-level types.
      • fromProperty

        public CodegenProperty fromProperty​(String name,
                                            io.swagger.v3.oas.models.media.Schema p,
                                            boolean required,
                                            boolean schemaIsFromAdditionalProperties)
        Description copied from class: DefaultCodegen
        Convert OAS Property object to Codegen Property object.

        The return value is cached. An internal cache is looked up to determine if the CodegenProperty return value has already been instantiated for the (String name, Schema p) arguments. Any subsequent processing of the CodegenModel return value must be idempotent for a given (String name, Schema schema).

        Overrides:
        fromProperty in class DefaultCodegen
        Parameters:
        name - name of the property
        p - OAS property schema
        required - true if the property is required in the next higher object schema, false otherwise
        schemaIsFromAdditionalProperties - true if the property is a required property defined by additional properties schema If this is the actual additionalProperties schema not defining a required property, then the value should be false
        Returns:
        Codegen Property object
      • explicitScalarDefaultValue

        protected String explicitScalarDefaultValue​(CodegenProperty property,
                                                    io.swagger.v3.oas.models.media.Schema schema)
      • toDefaultValue

        public String toDefaultValue​(io.swagger.v3.oas.models.media.Schema p)
        Description copied from class: DefaultCodegen
        Return the default value of the property

        This method should be overridden in the generator to meet its requirement. Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.

        Overrides:
        toDefaultValue in class DefaultCodegen
        Parameters:
        p - Property schema
        Returns:
        string presentation of the default value of the property
      • toDefaultValue

        public String toDefaultValue​(CodegenProperty codegenProperty,
                                     io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegen
        Return the default value of the property

        Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.

        Overrides:
        toDefaultValue in class DefaultCodegen
        Parameters:
        codegenProperty - Codegen property
        schema - Property schema
        Returns:
        string presentation of the default value of the property
      • setParameterEncodingValues

        public void setParameterEncodingValues​(CodegenParameter codegenParameter,
                                               io.swagger.v3.oas.models.media.MediaType mediaType)
        Description copied from class: DefaultCodegen
        Sets the content type, style, and explode of the parameter based on the encoding specified in the request body.
        Overrides:
        setParameterEncodingValues in class DefaultCodegen
        Parameters:
        codegenParameter - Codegen parameter
        mediaType - MediaType from the request body
      • rejectsUnsupportedFormEncodingStyles

        protected boolean rejectsUnsupportedFormEncodingStyles()
        Whether postProcessParameter(CodegenParameter) must fail closed on form parameters using space-delimited, pipe-delimited, or deep-object encodings. The client rejects them because its multipart writer cannot serialize them; generators whose runtime never parses form bodies at all (the server) override this to false so such fields follow the documented warn-and-drop degradation instead of aborting generation.
      • getSchemaType

        public String getSchemaType​(io.swagger.v3.oas.models.media.Schema p)
        Description copied from class: DefaultCodegen
        returns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type
        Overrides:
        getSchemaType in class DefaultCodegen
        Parameters:
        p - property schema
        Returns:
        string presentation of the type
      • refreshComponentSchemaIds

        protected void refreshComponentSchemaIds​(io.swagger.v3.oas.models.OpenAPI openApi)
      • applySharedCppOptions

        protected void applySharedCppOptions()
        Shared namespace/validation options common to client and server generators.
      • validateFormatAssertionPolicyOption

        protected void validateFormatAssertionPolicyOption()
        Validates the optional formatAssertionPolicy knob and pins the supported policy. Extracted so the client generator can preserve its historical validation precedence (format before sseSchemaMode).
      • captureOperationMetadata

        protected void captureOperationMetadata​(io.swagger.v3.oas.models.OpenAPI openAPI)
      • toPreprocessorIdentifier

        protected static String toPreprocessorIdentifier​(String value)
      • resolveThroughAliases

        protected String resolveThroughAliases​(String typeName)
        Resolves a type name transitively through the resolvedAliasTypes map. For example, if ModelIdsResponses → std::string and ModelIdsShared → std::string, then resolveThroughAliases("ModelIdsResponses") returns "std::string".

        Cyclic alias maps fail generation; an unmapped type is returned unchanged.

      • detectNullUnion

        protected String detectNullUnion​(io.swagger.v3.oas.models.media.Schema schema,
                                         String className)
        Detects whether a schema is a null union (anyOf/oneOf with [T, null] or [null, T]) that should lower to std::optional<T>. Returns the lowered type string, or null if the schema is not a simple null union.
      • stripSharedPtr

        protected static String stripSharedPtr​(String type)
        Recursively strips std::shared_ptr<X> wrappers from a type string.
        • std::shared_ptr<Foo> → Foo
        • std::vector<std::shared_ptr<Foo>> → std::vector<Foo>
        • std::map<std::string, std::shared_ptr<Foo>> → std::map<std::string, Foo>
        • std::string → std::string (unchanged)