forked from loafle/openapi-generator-original
Supports: All OpenAPI 3.x data types: primitives, arrays, enums, nullable/optional fields, nested objects All parameter types: path, query, header, cookie, and combinations Schema composition: allOf (inheritance), oneOf (discriminated unions), anyOf (flexible unions) Security schemes: API key and bearer token authentication Discriminator-based polymorphic deserialization and error handling Provides: Error handling for invalid JSON, type mismatches, missing/unknown discriminator, and parameter validation Build system integration (CMake) for easy compilation and linking with required dependencies Clear build and run instructions for local development and testing Enables comprehensive, real-world validation of generated C++ server code against OpenAPI specifications
113 lines
4.3 KiB
C++
113 lines
4.3 KiB
C++
/**
|
|
* This file is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
* https://openapi-generator.tech
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
// System headers
|
|
#include <httplib.h>
|
|
#include <memory>
|
|
#include <variant>
|
|
#include <optional>
|
|
|
|
// Project headers
|
|
#include "models/Dog.h"
|
|
#include "models/PaymentMethod.h"
|
|
#include "models/StringOrNumber.h"
|
|
|
|
namespace api {
|
|
class AuthenticationManager;
|
|
class Composition {
|
|
public:
|
|
Composition() = default;
|
|
virtual ~Composition() = default;
|
|
/**
|
|
* @brief Register all routes for this API
|
|
* @param svr The httplib::Server instance to register routes on
|
|
*/
|
|
void registerRoutes(httplib::Server& svr);
|
|
// =========================
|
|
// ===== Request types =====
|
|
// =========================
|
|
|
|
/**
|
|
* @brief Request type for handlePostForCompositionallof.
|
|
*/
|
|
struct CompositionallofPostRequest
|
|
{
|
|
models::Dog m_request; //Request Body (required)
|
|
};
|
|
|
|
/**
|
|
* @brief Request type for handlePostForCompositionanyof.
|
|
*/
|
|
struct CompositionanyofPostRequest
|
|
{
|
|
models::StringOrNumber m_request; //Request Body (required)
|
|
};
|
|
|
|
/**
|
|
* @brief Request type for handlePostForCompositiononeof.
|
|
*/
|
|
struct CompositiononeofPostRequest
|
|
{
|
|
models::PaymentMethod m_request; //Request Body (required)
|
|
};
|
|
|
|
// ==========================
|
|
// ===== Response types =====
|
|
// ==========================
|
|
|
|
/**
|
|
* @brief Response type for handlePostForCompositionallof.
|
|
*/
|
|
using CompositionallofPostResponse = models::Dog;
|
|
|
|
/**
|
|
* @brief Response type for handlePostForCompositionanyof.
|
|
*/
|
|
using CompositionanyofPostResponse = models::StringOrNumber;
|
|
|
|
/**
|
|
* @brief Response type for handlePostForCompositiononeof.
|
|
*/
|
|
using CompositiononeofPostResponse = models::PaymentMethod;
|
|
// ============================================================
|
|
// ===== Pure virtual functions to be handled by the user =====
|
|
// ============================================================
|
|
/**
|
|
* CompositionallofPostRequest - struct containing all the query parameters and headers and schemas as available.
|
|
* @return CompositionallofPostResponse The response type returned by the handler.
|
|
*/
|
|
virtual CompositionallofPostResponse handlePostForCompositionallof(const CompositionallofPostRequest& params)=0;
|
|
|
|
/**
|
|
* CompositionanyofPostRequest - struct containing all the query parameters and headers and schemas as available.
|
|
* @return CompositionanyofPostResponse The response type returned by the handler.
|
|
*/
|
|
virtual CompositionanyofPostResponse handlePostForCompositionanyof(const CompositionanyofPostRequest& params)=0;
|
|
|
|
/**
|
|
* CompositiononeofPostRequest - struct containing all the query parameters and headers and schemas as available.
|
|
* @return CompositiononeofPostResponse The response type returned by the handler.
|
|
*/
|
|
virtual CompositiononeofPostResponse handlePostForCompositiononeof(const CompositiononeofPostRequest& params)=0;
|
|
|
|
private:
|
|
// ========================================
|
|
// ===== Helper function declarations =====
|
|
// ========================================
|
|
static bool parseCompositionallofPostParams(const httplib::Request& req, CompositionallofPostRequest& params, std::vector<std::string>& paramErrors);
|
|
void handleCompositionallofPostRequest(const httplib::Request& req, httplib::Response& res);
|
|
static void handleCompositionallofPostResponse(const CompositionallofPostResponse& result, httplib::Response& res);
|
|
static bool parseCompositionanyofPostParams(const httplib::Request& req, CompositionanyofPostRequest& params, std::vector<std::string>& paramErrors);
|
|
void handleCompositionanyofPostRequest(const httplib::Request& req, httplib::Response& res);
|
|
static void handleCompositionanyofPostResponse(const CompositionanyofPostResponse& result, httplib::Response& res);
|
|
static bool parseCompositiononeofPostParams(const httplib::Request& req, CompositiononeofPostRequest& params, std::vector<std::string>& paramErrors);
|
|
void handleCompositiononeofPostRequest(const httplib::Request& req, httplib::Response& res);
|
|
static void handleCompositiononeofPostResponse(const CompositiononeofPostResponse& result, httplib::Response& res);
|
|
};
|
|
|
|
} // namespace api
|