Modern C++ 20 compile time OpenAPI parser and code generator implementation

OpenApi++ : openapipp

This is a proof of concept, currently under active work to become the best OpenAPI implementation for C++.

It allows compile time C++ code generation for an OpenAPI configuration.

To compile the project and pull dependencies run

Get a free tipi by registering to tipi.build

tipi . -t macos-cxx20

CppCon 2021 Talk

Featured in the CppCon 2021 Talks : Our Adventures With REST API in C++ : Making it Easy.

OpenApi JSON Compile Time client generation

Add the content of the petstore openapi.json to a C++ constexpr variable prefixed by _cx_json.

{}; using pre::cx::key_value_pair; auto reply = client.call_operation<"addPet">(std::make_tuple( key_value_pair<"id" , int> {43}, key_value_pair<"name" , std::string> {"Haskell"s}, key_value_pair<"photoUrls" , std::vector > { {"little_cat.png"s} } )); ">
  static constexpr auto openapi_json = R"x( 
  {
    "openapi": "3.0.2",
    "info": {
      "title": "Swagger Petstore - OpenAPI 3.0",
      "description": "This is a sample Pet Store Server.",
      "termsOfService": "http://swagger.io/terms/",
      "contact": {
        "email": "[email protected]"
      },
      "license": {
        "name": "Apache 2.0",
        "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
      },
      "version": "1.0.6"
      
    }
    ...
    ...
    ...
    ...
  })x"_cx_json

  constexpr auto client = client_t
    {};
  
    using pre::cx::key_value_pair;

  
    auto reply = client.call_operation<
    "addPet">(std::make_tuple(
    key_value_pair<
    "id" , 
    int>  {
    43},
    key_value_pair<
    "name" , std::string>  {
    "Haskell"s},
    key_value_pair<
    "photoUrls" , std::vector
    
     >  { {
     "little_cat.png"s} }
  ));
    
   

Generate "C++ Typings" for autocompletion support

mp11::mp_rename
    print_code{};
  

This will print the code to #include <> on a later build, that allows you then to use this syntax for the HTTP POST /Pet remote call:

auto second_reply = addPet(Pet{{43}, {"Haskell junior"s}, {{"some_cat.png"}} }); 

`

Libraries used in this work

Owner
tipi.build
The C and C++ compiler-as-a-service
tipi.build
Similar Resources

Einsums in C++ Provides compile-time contraction pattern analysis to determine optimal operation to perform

Einsums in C++  Provides compile-time contraction pattern analysis to determine optimal operation to perform

Einsums in C++ Provides compile-time contraction pattern analysis to determine optimal operation to perform. Examples This will optimize at compile-ti

Dec 2, 2022

Run-time program generator embedded in C++

Run-time program generator embedded in C++

Aug 5, 2022

A code generator for C++ projects.

Cmple A code preprocessor/generator for C++ cross-platform projects. This utility transforms simplified C++ source code files into fully-functional co

Sep 17, 2022

A simple implementation of a parser and its use to calculate simple mathematical expressions

Calculator C Parser A simple implementation of a parser and its use to calculate simple mathematical expressions I haven't written a detailed descript

Nov 8, 2021

In DFS-BFS Implementation In One Program Using Switch Case I am Using an Simple And Efficient Code of DFS-BFS Implementation.

In DFS-BFS Implementation In One Program Using Switch Case I am Using an Simple And Efficient Code of DFS-BFS Implementation.

DFS-BFS Implementation-In-One-Program-Using-Switch-Case-in-C Keywords : Depth First Search(DFS), Breadth First Search(BFS) In Depth First Search(DFS),

Nov 17, 2021

Updates the Wii's current system time with the real world time.

Fix Wii System Time This is a homebrew tool I made for the Wii a while ago. It updates the current system time with the real world time via worldtimea

Nov 9, 2022

Project PLS is developed based on icarus iverilog and will compile verilog into a much faster optimized model.

Getting Started with PLS The project is developed based on icarus iverilog. Special thanks to Stephen Williams ([email protected]). PLS is a Verilog si

Nov 8, 2022

A commented version of my libft, with details about how my algorithms work and simple main functions to compile them.

A commented version of my libft, with details about how my algorithms work and simple main functions to compile them.

LIBFT COMMENTED VERSION : 🔧 PART I : 📖 FT_STRCHR : 🔧 PART II : 📖 FT_SUBSTR : /* * DEFINITION : * CREATES A SUBSTRING FROM A STRING WITH PREDETER

Nov 11, 2021

Read-Compile-Run-Loop: tiny and powerful interactive C++ compiler (REPL)

Read-Compile-Run-Loop: tiny and powerful interactive C++ compiler (REPL) RCRL is a tiny engine for interactive C++ compilation and execution (implemen

Nov 25, 2022
A C++ 17 implementation of qntm's base65536 that runs at compile time

A C++ 17 implementation of qntm's base65536 that runs at compile time. With alternatives for C++ 11 and C++ 14 that runs at runtime. Useage: At compil

Feb 13, 2022
Entity-Component-System (ECS) with a focus on ease-of-use, runtime extensibility and compile-time type safety and clarity.
Entity-Component-System (ECS) with a focus on ease-of-use, runtime extensibility and compile-time type safety and clarity.

Kengine The Koala engine is a type-safe and self-documenting implementation of an Entity-Component-System (ECS), with a focus on runtime extensibility

Nov 10, 2022
DimensionalAnalysis - A compact C++ header-only library providing compile-time dimensional analysis and unit awareness

Dimwits ...or DIMensional analysis With unITS is a C++14 library for compile-time dimensional analysis and unit awareness. Minimal Example #include <i

Jul 8, 2022
Fast C/C++ CSS Parser (Cascading Style Sheets Parser)

MyCSS — a pure C CSS parser MyCSS is a fast CSS Parser implemented as a pure C99 library with the ability to build without dependencies. Mailing List:

Sep 22, 2022
Type safe - Zero overhead utilities for preventing bugs at compile time

type_safe type_safe provides zero overhead abstractions that use the C++ type system to prevent bugs. Zero overhead abstractions here and in following

Nov 27, 2022
Pipet - c++ library for building lightweight processing pipeline at compile-time for string obfuscation, aes ciphering or whatever you want

Pipet Pipet is a lightweight c++17 headers-only library than can be used to build simple processing pipelines at compile time. Features Compile-time p

Jul 30, 2022
Compile-time C Compiler implemented as C++14 constant expressions

constexpr-8cc: Compile-time C Compiler constexpr-8cc is a compile-time C compiler implemented as C++14 constant expressions. This enables you to compi

Nov 30, 2022
Set of tests to benchmark the compile time of c++ constructs

CompileTimer Set of tests to benchmark the compile time of c++ constructs This project is an attempt to understand what c++ construct take how much ti

Sep 21, 2019
[WIP] Experimental C++14 multithreaded compile-time entity-component-system library.

ecst Experimental & work-in-progress C++14 multithreaded compile-time Entity-Component-System header-only library. Overview Successful development of

Nov 20, 2022