diff --git a/.github/workflows/samples-cpp-oatpp-server.yaml b/.github/workflows/samples-cpp-oatpp-server.yaml
new file mode 100644
index 00000000000..12ad210e587
--- /dev/null
+++ b/.github/workflows/samples-cpp-oatpp-server.yaml
@@ -0,0 +1,30 @@
+name: Samples cpp oat++ server
+
+on:
+ push:
+ branches:
+ - "samples/server/petstore/cpp-oatpp/**"
+ pull_request:
+ paths:
+ - "samples/server/petstore/cpp-oatpp/**"
+
+env:
+ GRADLE_VERSION: 6.9
+
+jobs:
+ build:
+ name: Build cpp qt client
+ strategy:
+ matrix:
+ sample:
+ - samples/server/petstore/cpp-oatpp
+ os:
+ - ubuntu-latest
+ - macOS-latest
+ - windows-latest
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: Build
+ working-directory: ${{ matrix.sample }}
+ run: cmake -B build && cmake --build build --verbose
diff --git a/README.md b/README.md
index 5fdc6b19f1a..724760d8a07 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
| -------------------------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, Spring 6 RestClient, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **N4JS**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), **Swift** (2.x, 3.x, 4.x, 5.x, 6.x), **Typescript** (AngularJS, Angular (9.x - 19.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
-| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** ([Flight](https://docs.flightphp.com/), Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
+| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Oat++, Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** ([Flight](https://docs.flightphp.com/), Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Postman Collection**, **Protocol Buffer**, **WSDL** |
@@ -1128,6 +1128,7 @@ Here is a list of template creators:
* C# Azure functions: @Abrhm7786
* C# NancyFX: @mstefaniuk
* C++ (Qt5 QHttpEngine): @etherealjoy
+ * C++ Oat++: @Kraust
* C++ Pistache: @sebymiano
* C++ Restbed: @stkrwork
* Erlang Server: @galaxie @nelsonvides
diff --git a/bin/configs/cpp-oatpp-server-cpp-oatpp.yaml b/bin/configs/cpp-oatpp-server-cpp-oatpp.yaml
new file mode 100644
index 00000000000..cc328b503fd
--- /dev/null
+++ b/bin/configs/cpp-oatpp-server-cpp-oatpp.yaml
@@ -0,0 +1,6 @@
+generatorName: cpp-oatpp-server
+outputDir: samples/server/petstore/cpp-oatpp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/cpp-oatpp-server
+additionalProperties:
+ addExternalLibs: "true"
diff --git a/docs/generators.md b/docs/generators.md
index 4c968c0f87a..753014a50b9 100644
--- a/docs/generators.md
+++ b/docs/generators.md
@@ -87,6 +87,7 @@ The following generators are available:
* [ada-server](generators/ada-server.md)
* [aspnet-fastendpoints](generators/aspnet-fastendpoints.md)
* [aspnetcore](generators/aspnetcore.md)
+* [cpp-oatpp-server](generators/cpp-oatpp-server.md)
* [cpp-pistache-server](generators/cpp-pistache-server.md)
* [cpp-qt-qhttpengine-server](generators/cpp-qt-qhttpengine-server.md)
* [cpp-restbed-server](generators/cpp-restbed-server.md)
diff --git a/docs/generators/README.md b/docs/generators/README.md
index c9c48556912..d61f00351d5 100644
--- a/docs/generators/README.md
+++ b/docs/generators/README.md
@@ -65,6 +65,7 @@ The following generators are available:
## SERVER generators
* [ada-server](ada-server.md)
* [aspnetcore](aspnetcore.md)
+* [cpp-oatpp-server](cpp-oatpp-server.md)
* [cpp-pistache-server](cpp-pistache-server.md)
* [cpp-qt5-qhttpengine-server](cpp-qt5-qhttpengine-server.md)
* [cpp-restbed-server](cpp-restbed-server.md)
diff --git a/docs/generators/cpp-oatpp-server.md b/docs/generators/cpp-oatpp-server.md
new file mode 100644
index 00000000000..72bb7de1fc1
--- /dev/null
+++ b/docs/generators/cpp-oatpp-server.md
@@ -0,0 +1,262 @@
+---
+title: Documentation for the cpp-oatpp-server Generator
+---
+
+## METADATA
+
+| Property | Value | Notes |
+| -------- | ----- | ----- |
+| generator name | cpp-oatpp-server | pass this to the generate command after -g |
+| generator stability | STABLE | |
+| generator type | SERVER | |
+| generator language | C++ | |
+| generator default templating engine | mustache | |
+| helpTxt | Generates a C++ API server (based on Oat++) | |
+
+## CONFIG OPTIONS
+These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
+
+| Option | Description | Values | Default |
+| ------ | ----------- | ------ | ------- |
+|addExternalLibs|Add the Possibility to fetch and compile external Libraries needed by this Framework.| |true|
+|reservedWordPrefix|Prefix to prepend to reserved words in order to avoid conflicts| |r_|
+|variableNameFirstCharacterUppercase|Make first character of variable name uppercase (eg. value -> Value)| |true|
+
+## IMPORT MAPPING
+
+| Type/Alias | Imports |
+| ---------- | ------- |
+
+
+## INSTANTIATION TYPES
+
+| Type/Alias | Instantiated By |
+| ---------- | --------------- |
+
+
+## LANGUAGE PRIMITIVES
+
+
+- oatpp::Any
+- oatpp::Boolean
+- oatpp::Fields
+- oatpp::Float64
+- oatpp::Int32
+- oatpp::Int64
+- oatpp::Object
+- oatpp::String
+- oatpp::UnorderedSet
+- oatpp::Vector
+
+
+## RESERVED WORDS
+
+
+- NULL
+- alignas
+- alignof
+- and
+- and_eq
+- asm
+- auto
+- bitand
+- bitor
+- bool
+- break
+- case
+- catch
+- char
+- char16_t
+- char32_t
+- class
+- compl
+- concept
+- const
+- const_cast
+- constexpr
+- continue
+- decltype
+- default
+- delete
+- do
+- double
+- dynamic_cast
+- else
+- enum
+- explicit
+- export
+- extern
+- false
+- float
+- for
+- friend
+- goto
+- if
+- inline
+- int
+- linux
+- long
+- mutable
+- namespace
+- new
+- noexcept
+- not
+- not_eq
+- nullptr
+- operator
+- or
+- or_eq
+- private
+- protected
+- public
+- register
+- reinterpret_cast
+- requires
+- return
+- short
+- signed
+- sizeof
+- static
+- static_assert
+- static_cast
+- struct
+- switch
+- template
+- this
+- thread_local
+- throw
+- true
+- try
+- typedef
+- typeid
+- typename
+- union
+- unsigned
+- using
+- virtual
+- void
+- volatile
+- wchar_t
+- while
+- xor
+- xor_eq
+
+
+## FEATURE SET
+
+
+### Client Modification Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|BasePath|✗|ToolingExtension
+|Authorizations|✗|ToolingExtension
+|UserAgent|✗|ToolingExtension
+|MockServer|✗|ToolingExtension
+
+### Data Type Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Custom|✗|OAS2,OAS3
+|Int32|✓|OAS2,OAS3
+|Int64|✓|OAS2,OAS3
+|Float|✓|OAS2,OAS3
+|Double|✓|OAS2,OAS3
+|Decimal|✓|ToolingExtension
+|String|✓|OAS2,OAS3
+|Byte|✓|OAS2,OAS3
+|Binary|✓|OAS2,OAS3
+|Boolean|✓|OAS2,OAS3
+|Date|✓|OAS2,OAS3
+|DateTime|✓|OAS2,OAS3
+|Password|✓|OAS2,OAS3
+|File|✓|OAS2
+|Uuid|✗|
+|Array|✓|OAS2,OAS3
+|Null|✗|OAS3
+|AnyType|✗|OAS2,OAS3
+|Object|✓|OAS2,OAS3
+|Maps|✓|ToolingExtension
+|CollectionFormat|✓|OAS2
+|CollectionFormatMulti|✓|OAS2
+|Enum|✓|OAS2,OAS3
+|ArrayOfEnum|✓|ToolingExtension
+|ArrayOfModel|✓|ToolingExtension
+|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
+|ArrayOfCollectionOfModel|✓|ToolingExtension
+|ArrayOfCollectionOfEnum|✓|ToolingExtension
+|MapOfEnum|✓|ToolingExtension
+|MapOfModel|✓|ToolingExtension
+|MapOfCollectionOfPrimitives|✓|ToolingExtension
+|MapOfCollectionOfModel|✓|ToolingExtension
+|MapOfCollectionOfEnum|✓|ToolingExtension
+
+### Documentation Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Readme|✓|ToolingExtension
+|Model|✓|ToolingExtension
+|Api|✓|ToolingExtension
+
+### Global Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Host|✓|OAS2,OAS3
+|BasePath|✓|OAS2,OAS3
+|Info|✓|OAS2,OAS3
+|Schemes|✗|OAS2,OAS3
+|PartialSchemes|✓|OAS2,OAS3
+|Consumes|✓|OAS2
+|Produces|✓|OAS2
+|ExternalDocumentation|✓|OAS2,OAS3
+|Examples|✓|OAS2,OAS3
+|XMLStructureDefinitions|✗|OAS2,OAS3
+|MultiServer|✗|OAS3
+|ParameterizedServer|✗|OAS3
+|ParameterStyling|✗|OAS3
+|Callbacks|✗|OAS3
+|LinkObjects|✗|OAS3
+
+### Parameter Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Path|✓|OAS2,OAS3
+|Query|✓|OAS2,OAS3
+|Header|✓|OAS2,OAS3
+|Body|✓|OAS2
+|FormUnencoded|✓|OAS2
+|FormMultipart|✓|OAS2
+|Cookie|✗|OAS3
+
+### Schema Support Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Simple|✓|OAS2,OAS3
+|Composite|✓|OAS2,OAS3
+|Polymorphism|✗|OAS2,OAS3
+|Union|✗|OAS3
+|allOf|✗|OAS2,OAS3
+|anyOf|✗|OAS3
+|oneOf|✗|OAS3
+|not|✗|OAS3
+
+### Security Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|BasicAuth|✗|OAS2,OAS3
+|ApiKey|✗|OAS2,OAS3
+|OpenIDConnect|✗|OAS3
+|BearerToken|✗|OAS3
+|OAuth2_Implicit|✗|OAS2,OAS3
+|OAuth2_Password|✗|OAS2,OAS3
+|OAuth2_ClientCredentials|✗|OAS2,OAS3
+|OAuth2_AuthorizationCode|✗|OAS2,OAS3
+|SignatureAuth|✗|OAS3
+|AWSV4Signature|✗|ToolingExtension
+
+### Wire Format Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|JSON|✓|OAS2,OAS3
+|XML|✓|OAS2,OAS3
+|PROTOBUF|✗|ToolingExtension
+|Custom|✗|OAS2,OAS3
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppOatppServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppOatppServerCodegen.java
new file mode 100644
index 00000000000..548cb503ae4
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppOatppServerCodegen.java
@@ -0,0 +1,503 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ * Copyright 2018 SmartBear Software
+ *
+ * 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.Operation;
+import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.responses.ApiResponse;
+import io.swagger.v3.oas.models.servers.Server;
+import org.apache.commons.lang3.StringUtils;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.meta.features.*;
+import org.openapitools.codegen.model.ModelMap;
+import org.openapitools.codegen.model.OperationMap;
+import org.openapitools.codegen.model.OperationsMap;
+import org.openapitools.codegen.utils.ModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.*;
+import java.util.function.Predicate;
+
+import static org.openapitools.codegen.utils.StringUtils.underscore;
+
+public class CppOatppServerCodegen extends AbstractCppCodegen {
+ private final Logger LOGGER = LoggerFactory.getLogger(CppOatppServerCodegen.class);
+
+ protected String implFolder = "impl";
+ protected boolean isAddExternalLibs = true;
+ public static final String OPTIONAL_EXTERNAL_LIB = "addExternalLibs";
+ public static final String OPTIONAL_EXTERNAL_LIB_DESC = "Add the Possibility to fetch and compile external Libraries needed by this Framework.";
+ protected final String PREFIX = "";
+
+ @Override
+ public CodegenType getTag() {
+ return CodegenType.SERVER;
+ }
+
+ @Override
+ public String getName() {
+ return "cpp-oatpp-server";
+ }
+
+ @Override
+ public String getHelp() {
+ return "Generates a C++ API server (based on Oat++)";
+ }
+
+ public CppOatppServerCodegen() {
+ super();
+
+ // TODO: cpp-oatpp-server maintainer review
+ modifyFeatureSet(features -> features
+ .includeDocumentationFeatures(DocumentationFeature.Readme)
+ .securityFeatures(EnumSet.noneOf(SecurityFeature.class))
+ .excludeGlobalFeatures(
+ GlobalFeature.XMLStructureDefinitions,
+ GlobalFeature.Callbacks,
+ GlobalFeature.LinkObjects,
+ GlobalFeature.ParameterStyling,
+ GlobalFeature.MultiServer)
+ .excludeSchemaSupportFeatures(
+ SchemaSupportFeature.Polymorphism)
+ .excludeParameterFeatures(
+ ParameterFeature.Cookie));
+
+ if (StringUtils.isEmpty(modelNamePrefix)) {
+ modelNamePrefix = PREFIX;
+ }
+
+ apiPackage = "org.openapitools.server.api";
+ modelPackage = "org.openapitools.server.model";
+
+ apiTemplateFiles.put("api-header.mustache", ".hpp");
+ apiTemplateFiles.put("api-impl-header.mustache", ".hpp");
+ apiTemplateFiles.put("api-impl-source.mustache", ".cpp");
+
+ modelTemplateFiles.put("model-header.mustache", ".hpp");
+
+ embeddedTemplateDir = templateDir = "cpp-oatpp-server";
+
+ cliOptions.clear();
+ addSwitch(OPTIONAL_EXTERNAL_LIB, OPTIONAL_EXTERNAL_LIB_DESC, this.isAddExternalLibs);
+ addOption(RESERVED_WORD_PREFIX_OPTION, RESERVED_WORD_PREFIX_DESC, this.reservedWordPrefix);
+ addOption(VARIABLE_NAME_FIRST_CHARACTER_UPPERCASE_OPTION,
+ VARIABLE_NAME_FIRST_CHARACTER_UPPERCASE_DESC,
+ Boolean.toString(this.variableNameFirstCharacterUppercase));
+
+ setupSupportingFiles();
+
+ languageSpecificPrimitives = new HashSet<>(
+ Arrays.asList(
+ "oatpp::String",
+ "oatpp::Boolean",
+ "oatpp::Int32",
+ "oatpp::Int64",
+ "oatpp::Vector",
+ "oatpp::Fields",
+ "oatpp::UnorderedSet",
+ "oatpp::Object",
+ "oatpp::Float64",
+ "oatpp::Any"
+ ));
+
+ typeMapping = new HashMap<>();
+ typeMapping.put("date", "oatpp::String");
+ typeMapping.put("DateTime", "oatpp::String");
+ typeMapping.put("string", "oatpp::String");
+ typeMapping.put("integer", "oatpp::Int32");
+ typeMapping.put("long", "oatpp::Int64");
+ typeMapping.put("boolean", "oatpp::Boolean");
+ typeMapping.put("array", "oatpp::Vector");
+ typeMapping.put("map", "oatpp::Fields");
+ typeMapping.put("set", "oatpp::UnorderedSet");
+ typeMapping.put("file", "oatpp::String");
+ typeMapping.put("object", "oatpp::Object");
+ typeMapping.put("binary", "oatpp::String");
+ typeMapping.put("number", "oatpp::Float64");
+ typeMapping.put("UUID", "oatpp::String");
+ typeMapping.put("URI", "oatpp::String");
+ typeMapping.put("ByteArray", "oatpp::String");
+ typeMapping.put("AnyType", "oatpp::Any");
+
+ super.importMapping = new HashMap<>();
+ }
+
+ private void setupSupportingFiles() {
+ supportingFiles.clear();
+ supportingFiles
+ .add(new SupportingFile("main-api-server.mustache", "", modelNamePrefix + "main-api-server.cpp"));
+ supportingFiles.add(new SupportingFile("cmake.mustache", "", "CMakeLists.txt"));
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+ if (additionalProperties.containsKey("modelNamePrefix")) {
+ additionalProperties().put("prefix", modelNamePrefix);
+ setupSupportingFiles();
+ }
+ if (additionalProperties.containsKey(RESERVED_WORD_PREFIX_OPTION)) {
+ reservedWordPrefix = (String) additionalProperties.get(RESERVED_WORD_PREFIX_OPTION);
+ }
+
+ additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\."));
+ additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::"));
+ additionalProperties.put("apiNamespaceDeclarations", apiPackage.split("\\."));
+ additionalProperties.put("apiNamespace", apiPackage.replaceAll("\\.", "::"));
+ additionalProperties.put(RESERVED_WORD_PREFIX_OPTION, reservedWordPrefix);
+
+ if (additionalProperties.containsKey(OPTIONAL_EXTERNAL_LIB)) {
+ setAddExternalLibs(convertPropertyToBooleanAndWriteBack(OPTIONAL_EXTERNAL_LIB));
+ } else {
+ additionalProperties.put(OPTIONAL_EXTERNAL_LIB, isAddExternalLibs);
+ }
+ }
+
+ @Override
+ public String toModelImport(String name) {
+ if (importMapping.containsKey(name)) {
+ return importMapping.get(name);
+ } else {
+ return "#include \"" + name + ".hpp\"";
+ }
+ }
+
+ @Override
+ public CodegenModel fromModel(String name, Schema model) {
+ CodegenModel codegenModel = super.fromModel(name, model);
+
+ Set oldImports = codegenModel.imports;
+ codegenModel.imports = new HashSet<>();
+ for (String imp : oldImports) {
+ String newImp = toModelImport(imp);
+ if (!newImp.isEmpty()) {
+ codegenModel.imports.add(newImp);
+ }
+ }
+
+ if (!codegenModel.isEnum
+ && codegenModel.anyOf.size() > 1
+ && codegenModel.anyOf.contains("std::string")
+ && !codegenModel.anyOf.contains("AnyType")
+ && codegenModel.interfaces.size() == 1) {
+ codegenModel.vendorExtensions.put("x-is-string-enum-container", true);
+ }
+ return codegenModel;
+ }
+
+ @Override
+ public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List servers) {
+ CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
+
+ if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
+ ApiResponse apiResponse = findMethodResponse(operation.getResponses());
+
+ if (apiResponse != null) {
+ Schema response = ModelUtils.getSchemaFromResponse(openAPI, apiResponse);
+ if (response != null) {
+ CodegenProperty cm = fromProperty("response", response, false);
+ op.vendorExtensions.put("x-codegen-response", cm);
+ if ("HttpContent".equals(cm.dataType)) {
+ op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
+ }
+ }
+ }
+ }
+
+ String pathForOatpp = path.replaceAll("\\{(.*?)}", "{$1}");
+ op.vendorExtensions.put("x-codegen-oatpp-path", pathForOatpp);
+
+ return op;
+ }
+
+ @Override
+ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) {
+ OperationMap operations = objs.getOperations();
+ String classname = operations.getClassname();
+ operations.put("classnameSnakeUpperCase", underscore(classname).toUpperCase(Locale.ROOT));
+ operations.put("classnameSnakeLowerCase", underscore(classname).toLowerCase(Locale.ROOT));
+ List operationList = operations.getOperation();
+ for (CodegenOperation op : operationList) {
+ postProcessSingleOperation(operations, op);
+ }
+
+ return objs;
+ }
+
+ private void postProcessSingleOperation(OperationMap operations, CodegenOperation op) {
+ if (op.vendorExtensions == null) {
+ op.vendorExtensions = new HashMap<>();
+ }
+
+ if (op.bodyParam != null) {
+ if (op.bodyParam.vendorExtensions == null) {
+ op.bodyParam.vendorExtensions = new HashMap<>();
+ }
+
+ boolean isStringOrDate = op.bodyParam.isString || op.bodyParam.isDate;
+ op.bodyParam.vendorExtensions.put("x-codegen-oatpp-is-string-or-date", isStringOrDate);
+ }
+
+ boolean consumeJson = false;
+ if (op.consumes != null) {
+ Predicate