() : e.getValue();
+ use.put("scopes", scopes);
+ use.put("scopesRendered", scopes.isEmpty() ? null
+ : scopes.stream()
+ .map(s -> "\"" + cppString(s) + "\"")
+ .collect(java.util.stream.Collectors
+ .joining(", ")));
+ ands.add(use);
+ }
+ }
+ groups.add(ands); // empty ands = {}
+ }
+ return groups;
+ }
+
+ /** The raw Operation behind a CodegenOperation (PathItem-method lookup). */
+ static io.swagger.v3.oas.models.Operation operationFor(
+ OpenAPI document, CodegenOperation op) {
+ if (document == null || document.getPaths() == null) {
+ return null;
+ }
+ PathItem item = document.getPaths().get(op.path);
+ if (item == null) {
+ return null;
+ }
+ if ("GET".equals(op.httpMethod)) {
+ return item.getGet();
+ }
+ if ("PUT".equals(op.httpMethod)) {
+ return item.getPut();
+ }
+ if ("POST".equals(op.httpMethod)) {
+ return item.getPost();
+ }
+ if ("DELETE".equals(op.httpMethod)) {
+ return item.getDelete();
+ }
+ if ("OPTIONS".equals(op.httpMethod)) {
+ return item.getOptions();
+ }
+ if ("HEAD".equals(op.httpMethod)) {
+ return item.getHead();
+ }
+ if ("PATCH".equals(op.httpMethod)) {
+ return item.getPatch();
+ }
+ if ("TRACE".equals(op.httpMethod)) {
+ return item.getTrace();
+ }
+ return null;
+ }
+
+ private static String cppString(String value) {
+ return CppBoostBeastModelCodegen.escapeCppStringContent(
+ value == null ? "" : value);
+ }
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastServerCodegen.java
new file mode 100644
index 000000000000..30b32046e95e
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastServerCodegen.java
@@ -0,0 +1,1160 @@
+/*
+ * Copyright 2026 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openapitools.codegen.languages;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.Operation;
+import io.swagger.v3.oas.models.PathItem;
+import io.swagger.v3.oas.models.media.Content;
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.parameters.RequestBody;
+import io.swagger.v3.oas.models.responses.ApiResponse;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import org.openapitools.codegen.utils.ModelUtils;
+import org.openapitools.codegen.CodegenType;
+import org.openapitools.codegen.SupportingFile;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.openapitools.codegen.meta.features.DataTypeFeature;
+import org.openapitools.codegen.meta.features.DocumentationFeature;
+import org.openapitools.codegen.meta.features.GlobalFeature;
+import org.openapitools.codegen.meta.features.ParameterFeature;
+import org.openapitools.codegen.meta.features.SchemaSupportFeature;
+import org.openapitools.codegen.meta.features.SecurityFeature;
+import org.openapitools.codegen.meta.features.WireFormatFeature;
+import org.openapitools.codegen.model.ModelMap;
+import org.openapitools.codegen.model.OperationsMap;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * C++ Boost.Beast HTTP server code generator. Emits an asynchronous
+ * HTTP/1.1 server (Boost.Beast + Boost.Asio + Boost.URL) with typed
+ * per-operation request/response contracts, OAS parameter deserialization,
+ * a pluggable security authorizer seam, RFC 9457 problem responses, and
+ * decode-time OAS 3.1 schema validation shared with the client generator.
+ *
+ * Mustache templates are located in
+ * {@code src/main/resources/cpp-boost-beast-server/} with shared
+ * model/validation templates resolved from {@code cpp-boost-beast-common}.
+ */
+public class CppBoostBeastServerCodegen extends CppBoostBeastModelCodegen {
+
+ public static final String DEFAULT_PACKAGE_NAME = "CppBoostBeastServer";
+ public static final String ADD_API_IMPL_STUBS = "addApiImplStubs";
+
+ protected String packageName = DEFAULT_PACKAGE_NAME;
+
+ @Override
+ public CodegenType getTag() {
+ return CodegenType.SERVER;
+ }
+
+ @Override
+ public String getName() {
+ return "cpp-boost-beast-server";
+ }
+
+ @Override
+ public String getHelp() {
+ return "Generates a C++ Boost.Beast HTTP server.";
+ }
+
+ public CppBoostBeastServerCodegen() {
+ super();
+ openapiNormalizer.put("NORMALIZER_CLASS",
+ CppBoostBeastClientCodegen.CppBoostBeastOpenAPINormalizer.class.getName());
+ generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
+ .stability(Stability.BETA)
+ .build();
+ modifyFeatureSet(features -> features
+ .includeDocumentationFeatures(DocumentationFeature.Readme)
+ .securityFeatures(EnumSet.of(
+ SecurityFeature.ApiKey,
+ SecurityFeature.BasicAuth,
+ SecurityFeature.BearerToken))
+ .wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON))
+ .includeGlobalFeatures(
+ GlobalFeature.ParameterStyling
+ )
+ .excludeGlobalFeatures(
+ GlobalFeature.XMLStructureDefinitions,
+ GlobalFeature.Callbacks,
+ GlobalFeature.LinkObjects,
+ // The generated Router registers operation paths
+ // verbatim and the server binds the endpoint the
+ // caller passes to listen(): the document's server
+ // URLs (host and any base path) are not mounted, so
+ // host, base-path, and multi-server routing are not
+ // implemented.
+ GlobalFeature.Host,
+ GlobalFeature.BasePath,
+ GlobalFeature.MultiServer
+ )
+ .excludeParameterFeatures(
+ // Non-JSON request bodies degrade to "no typed body"
+ // (see collectSurfaceWarnings): the runtime never
+ // parses urlencoded or multipart payloads.
+ ParameterFeature.FormUnencoded,
+ ParameterFeature.FormMultipart
+ )
+ .includeSchemaSupportFeatures(
+ SchemaSupportFeature.Polymorphism,
+ SchemaSupportFeature.Composite,
+ SchemaSupportFeature.oneOf,
+ SchemaSupportFeature.anyOf,
+ SchemaSupportFeature.allOf,
+ SchemaSupportFeature.not,
+ SchemaSupportFeature.Union
+ )
+ .includeDataTypeFeatures(
+ DataTypeFeature.Int32,
+ DataTypeFeature.Int64,
+ DataTypeFeature.Float,
+ DataTypeFeature.Double,
+ DataTypeFeature.String,
+ DataTypeFeature.Boolean,
+ DataTypeFeature.Enum,
+ DataTypeFeature.Array,
+ DataTypeFeature.Maps,
+ DataTypeFeature.Object,
+ DataTypeFeature.Null,
+ DataTypeFeature.AnyType
+ )
+ .excludeDataTypeFeatures(
+ DataTypeFeature.Decimal,
+ DataTypeFeature.Date,
+ DataTypeFeature.DateTime,
+ DataTypeFeature.Uuid,
+ DataTypeFeature.Byte,
+ DataTypeFeature.Binary,
+ DataTypeFeature.Password
+ )
+ .includeParameterFeatures(
+ ParameterFeature.Cookie
+ )
+ );
+
+ outputFolder = "generated-code" + File.separator + "cpp-boost-beast-server";
+ modelTemplateFiles.put("model-header.mustache", ".h");
+ modelTemplateFiles.put("model-source.mustache", ".cpp");
+ apiTemplateFiles.put("api-header.mustache", ".h");
+ apiTemplateFiles.put("api-source.mustache", ".cpp");
+
+ embeddedTemplateDir = templateDir = "cpp-boost-beast-server";
+
+ modelPackage = "org.openapitools.server.model";
+ apiPackage = "org.openapitools.server.api";
+
+ cliOptions.clear();
+
+ addOption(org.openapitools.codegen.CodegenConstants.PACKAGE_NAME,
+ "C++ package and library name.", DEFAULT_PACKAGE_NAME);
+ addOption(org.openapitools.codegen.CodegenConstants.MODEL_PACKAGE,
+ "C++ namespace for models (convention: name.space.model).", this.modelPackage);
+ addOption(org.openapitools.codegen.CodegenConstants.API_PACKAGE,
+ "C++ namespace for apis (convention: name.space.api).", this.apiPackage);
+ org.openapitools.codegen.CliOption compileWithValidationOption =
+ new org.openapitools.codegen.CliOption("compileWithValidation",
+ "Emit schema-validation IR and kValidateOnDecode=true in generated"
+ + " ValidationTypes.h (default). Set to false to omit the IR.");
+ compileWithValidationOption.defaultValue(Boolean.TRUE.toString());
+ cliOptions.add(compileWithValidationOption);
+ org.openapitools.codegen.CliOption tolerateOption =
+ new org.openapitools.codegen.CliOption(
+ "tolerateNonNullableNulls",
+ "Treat explicit JSON null values as absent for generated model"
+ + " properties whose schemas do not allow null. Enabled by"
+ + " default; set to false for strict schema decoding.");
+ tolerateOption.defaultValue(Boolean.TRUE.toString());
+ cliOptions.add(tolerateOption);
+ org.openapitools.codegen.CliOption preserveOption =
+ new org.openapitools.codegen.CliOption(
+ "preserveAdditionalProperties",
+ "Retain undeclared JSON object members in generated object models"
+ + " and re-emit them; set to false for strict handling.");
+ preserveOption.defaultValue(Boolean.FALSE.toString());
+ cliOptions.add(preserveOption);
+ org.openapitools.codegen.CliOption stubsOption =
+ org.openapitools.codegen.CliOption.newBoolean(
+ ADD_API_IMPL_STUBS,
+ "Generate API implementation stubs that answer 501 problem+json"
+ + " and a sample main.cpp for quick start");
+ stubsOption.defaultValue(Boolean.FALSE.toString());
+ cliOptions.add(stubsOption);
+
+ supportingFiles.add(new SupportingFile("validation-types.mustache", "model", "ValidationTypes.h"));
+ supportingFiles.add(new SupportingFile("NullableField.h.mustache", "model", "NullableField.h"));
+ supportingFiles.add(new SupportingFile("anytype-header.mustache", "model", "AnyType.h"));
+ supportingFiles.add(new SupportingFile(
+ "oas31_exact_number.mustache", "model", "Oas31ExactNumber.h"));
+ supportingFiles.add(new SupportingFile(
+ "oas31_exact_number_source.mustache", "model", "Oas31ExactNumber.cpp"));
+ supportingFiles.add(new SupportingFile("oas31_schema_ir.mustache", "model", "Oas31SchemaIr.h"));
+ supportingFiles.add(new SupportingFile("oas31_deep_equal.mustache", "model", "Oas31DeepEqual.h"));
+ supportingFiles.add(new SupportingFile("oas31_exact_json.mustache", "model", "Oas31ExactJson.h"));
+ supportingFiles.add(new SupportingFile("oas31_validator.mustache", "model", "Oas31Validator.h"));
+ supportingFiles.add(new SupportingFile(
+ "oas31_schema_ir_header.mustache", "model", "Oas31SchemaRegistry.h"));
+ supportingFiles.add(new SupportingFile(
+ "oas31_schema_ir_source.mustache", "model", "schema_ir.generated.cpp"));
+
+ supportingFiles.add(new SupportingFile("http-server-header.mustache", "server", "HttpServer.h"));
+ supportingFiles.add(new SupportingFile("http-server-source.mustache", "server", "HttpServer.cpp"));
+ supportingFiles.add(new SupportingFile("router-header.mustache", "server", "Router.h"));
+ supportingFiles.add(new SupportingFile("responder-header.mustache", "server", "Responder.h"));
+ supportingFiles.add(new SupportingFile("problem-header.mustache", "server", "Problem.h"));
+ supportingFiles.add(new SupportingFile("authorizer-header.mustache", "server", "Authorizer.h"));
+ supportingFiles.add(new SupportingFile("param-codecs-header.mustache", "server", "ParamCodecs.h"));
+ supportingFiles.add(new SupportingFile("body-json-header.mustache", "server", "BodyJson.h"));
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+ supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", "", "CMakeLists.txt"));
+
+ languageSpecificPrimitives = new HashSet(
+ Arrays.asList("int", "char", "bool", "long", "float", "double",
+ "std::int32_t", "std::int64_t"));
+
+ // Replace (do not inherit) the base maps: DefaultCodegen seeds
+ // AnyType -> oas_any_type_not_mapped, a placeholder header that no
+ // C++ template provides. Untyped schemas resolve through the model
+ // pipeline's isAnyType branch (boost::json::value); mirroring the
+ // client's wiped-map initialization keeps both generators on one
+ // convention.
+ super.typeMapping = new HashMap();
+ typeMapping.put("date", "std::string");
+ typeMapping.put("DateTime", "std::string");
+ typeMapping.put("string", "std::string");
+ typeMapping.put("integer", "std::int32_t");
+ typeMapping.put("long", "std::int64_t");
+ typeMapping.put("boolean", "bool");
+ typeMapping.put("array", "std::vector");
+ typeMapping.put("set", "std::vector");
+ typeMapping.put("map", "std::map");
+ typeMapping.put("file", "std::string");
+ typeMapping.put("object", "boost::json::value");
+ typeMapping.put("number", "double");
+ typeMapping.put("UUID", "std::string");
+ typeMapping.put("URI", "std::string");
+ typeMapping.put("ByteArray", "std::string");
+
+ importMapping.put("std::vector", "#include ");
+ importMapping.put("std::map", "#include