This is a 5 minutes tutorial how-to-use Oat++ (AKA oatpp) web framework to build your ownC++ performant web-service and integrate it with Swagger-UI.

Pre Requirements

  • For Mac/Linux: Git, build-essentials, CMake.
  • For Windows: Git, CMake, MSVC.

Install Oat++

Clone oatpp repo:

$ git clone https://github.com/oatpp/oatpp
$ cd oatpp/

On Mac/Linux:

$ mkdir build && cd build/
$ cmake ..
$ make install

For more detailed instructions see - installing Oat++ on Unix/Linux.

On Windows:

$ MD build
$ cd build/
$ cmake ..
$ cmake --build . --target INSTALL

For more detailed instructions see - installing Oat++ on Windows.

Now we are able to build services using Oat++. It is a zero-dependency framework, so NO additional installations are required.

Build and Run Starter Project

Clone “oatpp-starter”

$ git clone --depth=1 https://github.com/oatpp/oatpp-starter my-service
$ cd my-service/

Build “oatpp-starter” on Mac/Linux

$ mkdir build && cd build/
$ cmake ..
$ make

Build “oatpp-starter” on Windows

$ MD build
$ cd build/
$ cmake ..
$ cmake --build .

Run compiled executable:

  • Mac/Linux -
$ ./my-project-exe
  • Windows -
$ .\src\Debug\my-project-exe.exe

Now go to localhost:8000_ and m_ake sure that you can see the response from server

{"statusCode": 200, "message": "Hello World!"}

#web-development #swagger #api #cplusplus #developer

 C++ RESTful Web Service With Swagger-UI and Auto-Documented Endpoints
11.65 GEEK