Skip to content

Commit 474d239

Browse files
committed
Added httplib server codegen
Introduces: * Code generation for cpp httplib server * API and model namespace customization. * Custom project naming * Pure virtual functions with request model arguments for custom logic * apiNamespace, modelNamespace, projectName as additionalProperties * CMake library integration * Auto-generated API model usage README * gitworkflkow, sample json, sample generated code is added * Documentation for cpp-httplib-server codegen is also added.
1 parent df1d562 commit 474d239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5996
-3
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Samples cpp httplib server
2+
3+
on:
4+
push:
5+
branches:
6+
- "samples/server/petstore/cpp-httplib/**"
7+
pull_request:
8+
paths:
9+
- "samples/server/petstore/cpp-httplib/**"
10+
11+
env:
12+
GRADLE_VERSION: 6.9
13+
14+
jobs:
15+
build:
16+
name: Build cpp httplib server
17+
strategy:
18+
matrix:
19+
sample:
20+
- samples/server/petstore/cpp-httplib
21+
os:
22+
- ubuntu-latest
23+
- macOS-latest
24+
- windows-latest
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Install dependencies
29+
if: matrix.os == 'ubuntu-latest'
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install -y nlohmann-json3-dev libssl-dev
33+
# Install httplib from source since it's not in Ubuntu repos
34+
git clone https://github.com/yhirose/cpp-httplib.git
35+
cd cpp-httplib
36+
mkdir build && cd build
37+
cmake .. -DCMAKE_BUILD_TYPE=Release
38+
make -j$(nproc)
39+
sudo make install
40+
- name: Install dependencies
41+
if: matrix.os == 'macOS-latest'
42+
run: |
43+
brew install nlohmann-json openssl
44+
# Install httplib via Homebrew
45+
brew install cpp-httplib
46+
- name: Install dependencies
47+
if: matrix.os == 'windows-latest'
48+
run: |
49+
vcpkg install nlohmann-json:x64-windows openssl:x64-windows cpp-httplib:x64-windows
50+
shell: cmd
51+
- name: Build
52+
working-directory: ${{ matrix.sample }}
53+
run: cmake -B build && cmake --build build --verbose

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
9292
| | Languages/Frameworks |
9393
| -------------------------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9494
| **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** |
95-
| **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) |
95+
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Oat++, Pistache, Restbed, Qt5 QHTTPEngine, Httplib), **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) |
9696
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
9797
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
9898
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Postman Collection**, **Protocol Buffer**, **WSDL** |

bin/configs/cpp-httplib-petstore.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generatorName: cpp-httplib
2+
outputDir: samples/server/petstore/cpp-httplib-server
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/cpp-httplib-server/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/cpp-httplib
5+
additionalProperties:
6+
apiNamespace: "sample::openapi::api"
7+
modelNamespace: "sample::openapi::model"
8+
projectName: "SampleProject"

docs/generators.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ The following generators are available:
9191
* [cpp-pistache-server](generators/cpp-pistache-server.md)
9292
* [cpp-qt-qhttpengine-server](generators/cpp-qt-qhttpengine-server.md)
9393
* [cpp-restbed-server](generators/cpp-restbed-server.md)
94-
* [cpp-restbed-server-deprecated](generators/cpp-restbed-server-deprecated.md)
94+
* [cpp-restbed-server-deprecated](generators/cpp-restbed-server-deprecated.md)
95+
* [cpp-httplib-server](generators/cpp-httplib-server.md)
9596
* [csharp-functions](generators/csharp-functions.md)
9697
* [erlang-server](generators/erlang-server.md)
9798
* [erlang-server-deprecated (deprecated)](generators/erlang-server-deprecated.md)

docs/generators/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ The following generators are available:
6969
* [cpp-pistache-server](cpp-pistache-server.md)
7070
* [cpp-qt5-qhttpengine-server](cpp-qt5-qhttpengine-server.md)
7171
* [cpp-restbed-server](cpp-restbed-server.md)
72+
* [cpp-httplib-server](cpp-httplib-server.md)
7273
* [erlang-server](erlang-server.md)
7374
* [fsharp-functions (beta)](fsharp-functions.md)
7475
* [fsharp-giraffe-server (beta)](fsharp-giraffe-server.md)

0 commit comments

Comments
 (0)