Files
openapi-generator/samples/server/petstore/cpp-httplib-server/feature-test/models/Company.cpp
vasireddyrajesh b96334ffad Add standalone C++ server using cpp-httplib for OpenAPI-based APIs (#21724)
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
2026-02-12 19:41:05 +08:00

68 lines
1.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.
*/
#include "Company.h"
namespace models {
Company::Company()
: name("")
, headquarters(Address())
, departments(std::vector<Department>())
, metadata(std::map<std::string, nlohmann::json>())
{
}
// =========================================
// ===== Getters/Setters =====
// =========================================
// ===================
// ===== Getters =====
// ===================
std::string Company::getName() const
{
return name;
}
Address Company::getHeadquarters() const
{
return headquarters;
}
std::vector<Department> Company::getDepartments() const
{
return departments;
}
std::map<std::string, nlohmann::json> Company::getMetadata() const
{
return metadata;
}
// ===================
// ===== Setters =====
// ===================
void Company::setName(const std::string& nameObj)
{
name = nameObj;
}
void Company::setHeadquarters(const Address& headquartersObj)
{
headquarters = headquartersObj;
}
void Company::setDepartments(const std::vector<Department>& departmentsObj)
{
departments = departmentsObj;
}
void Company::setMetadata(const std::map<std::string, nlohmann::json>& metadataObj)
{
metadata = metadataObj;
}
} // namespace models