Bug Report Checklist
Description
When a top-level schema is defined as type: string with enum values and referenced via $ref, the cpp-httplib-server generator emits a class with only toJson() / fromJson() accessors but no actual enum class members and no enum values. The class is entirely hollow and cannot be used.
Inline enum definitions (defined directly on a property rather than in components/schemas) work correctly, but this is not acceptable when the same enum type is reused across multiple locations in the spec — deduplication via $ref is the correct OpenAPI pattern.
openapi-generator version
7.22.0
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
title: Enum Bug Reproduction
version: "1.0.0"
paths:
/example:
get:
operationId: getExample
parameters:
- in: query
name: status
schema:
$ref: '#/components/schemas/StatusEnum'
responses:
'200':
description: OK
components:
schemas:
StatusEnum:
type: string
enum:
- ACTIVE
- INACTIVE
- PENDING
Generation Details
Generated class has no member variables:
/**
* 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 <nlohmann/json.hpp>
namespace models {
class StatusEnum
{
public:
StatusEnum();
virtual ~StatusEnum() = default;
// Getters and setters
// JSON serialization using NLOHMANN INTRUSIVE macro (must be inside class to access private members)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(StatusEnum,
)
private:
};
} // namespace models
Expected output: should have created an enum class with ACTIVE, INACTIVE and PENDING.
Steps to reproduce
docker run --rm -v $PWD:/local openapitools/openapi-generator-cli:v7.22.0 generate -g cpp-httplib-server -i local/test.yml -o ./local/out
Related issues/PRs
#958 — Similar symptom on cpp-restsdk
#10301 — $ref enum causes compilation error on cpp-restsdk
Suggest a fix
It seems that the cpp-httplib codegen is missing handling for top-level enums, as other C++ generators don't have this problem.
Bug Report Checklist
Description
When a top-level schema is defined as type: string with enum values and referenced via $ref, the cpp-httplib-server generator emits a class with only toJson() / fromJson() accessors but no actual enum class members and no enum values. The class is entirely hollow and cannot be used.
Inline enum definitions (defined directly on a property rather than in components/schemas) work correctly, but this is not acceptable when the same enum type is reused across multiple locations in the spec — deduplication via $ref is the correct OpenAPI pattern.
openapi-generator version
7.22.0
OpenAPI declaration file content or url
Generation Details
Generated class has no member variables:
Expected output: should have created an enum class with ACTIVE, INACTIVE and PENDING.
Steps to reproduce
docker run --rm -v $PWD:/local openapitools/openapi-generator-cli:v7.22.0 generate -g cpp-httplib-server -i local/test.yml -o ./local/out
Related issues/PRs
#958 — Similar symptom on cpp-restsdk
#10301 — $ref enum causes compilation error on cpp-restsdk
Suggest a fix
It seems that the cpp-httplib codegen is missing handling for top-level enums, as other C++ generators don't have this problem.