Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1316
Closed
Open
Issue created Oct 25, 2018 by Administrator@rootContributor

[cpp-restsdk] Enumerations not generated

Created by: brianwaters3

Description

Currently the enumeration definition below generates a class with no members. The attached file archive.zip contains a complete definition (with several enumerations) that demonstrate this problem.

Archive.zip

openapi-generator version

v 3.3.0

OpenAPI declaration file content or url
    SupportedGADShapes:
      anyOf:
        - type: string
          enum:
            - POINT
            - POINT_UNCERTAINTY_CIRCLE
            - POINT_UNCERTAINTY_ELLIPSE
            - POLYGON
            - POINT_ALTITUDE
            - POINT_ALTITUDE_UNCERTAINTY
            - ELLIPSOID_ARC
        - type: string
Command line used for generation

java -jar /home/brian/code/git/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i updated/TS29122_MonitoringEvent.yaml -g cpp-restsdk --config config -o ./code/MonitoringEvent/client/cpp-restsdk

Steps to reproduce
  1. Create a blank working directory
  2. Unzip Archive.zip to the newly created directory.
  3. Generate the source using the provided command making path adjustments for your system.
  4. The class SupportedGADShapes in ./code/MonitoringEvent/client/cpp-restsdk/model/SupportedGADShapes.h has no members.
Related issues/PRs
Suggest a fix/enhancement

The attached file SupportedGADShapes.zip contains the .h and .cpp definitions for the enumeration. Note that an enumeration named "INVALID" has been added in the header and is used when no default is specified.

SupportedGADShapes.zip

...
    /////////////////////////////////////////////
    /// SupportedGADShapes members
    enum eSupportedGADShapes
    {
       INVALID,
       POINT,
       POINT_UNCERTAINTY_CIRCLE,
       POINT_UNCERTAINTY_ELLIPSE,
       POLYGON,
       POINT_ALTITUDE,
       POINT_ALTITUDE_UNCERTAINTY,
       ELLIPSOID_ARC
    };

    eSupportedGADShapes getValue() const;
    void setValue(eSupportedGADShapes const value);

protected:
    eSupportedGADShapes m_value;
...
...
web::json::value SupportedGADShapes::toJson() const
{
    web::json::value val = web::json::value::object();

    switch (m_value)
    {
       case eSupportedGADShapes::POINT:                        val = web::json::value::string(U("POINT"));  break;
       case eSupportedGADShapes::POINT_UNCERTAINTY_CIRCLE:     val = web::json::value::string(U("POINT_UNCERTAINTY_CIRCLE"));  break;
       case eSupportedGADShapes::POINT_UNCERTAINTY_ELLIPSE:    val = web::json::value::string(U("POINT_UNCERTAINTY_ELLIPSE"));  break;
       case eSupportedGADShapes::POLYGON:                      val = web::json::value::string(U("POLYGON"));  break;
       case eSupportedGADShapes::POINT_ALTITUDE:               val = web::json::value::string(U("POINT_ALTITUDE"));  break;
       case eSupportedGADShapes::POINT_ALTITUDE_UNCERTAINTY:   val = web::json::value::string(U("POINT_ALTITUDE_UNCERTAINTY"));  break;
       case eSupportedGADShapes::ELLIPSOID_ARC:                val = web::json::value::string(U("ELLIPSOID_ARC"));  break;
       default:                                                val = web::json::value::string(U("INVALID"));  break;
    }

    return val;
}

void SupportedGADShapes::fromJson(web::json::value& val)
{
   auto s = val.as_string();

   m_value =
         (s == "POINT")                        ? eSupportedGADShapes::POINT :
         (s == "POINT_UNCERTAINTY_CIRCLE")     ? eSupportedGADShapes::POINT_UNCERTAINTY_CIRCLE :
         (s == "POINT_UNCERTAINTY_ELLIPSE")    ? eSupportedGADShapes::POINT_UNCERTAINTY_ELLIPSE :
         (s == "POLYGON")                      ? eSupportedGADShapes::POLYGON :
         (s == "POINT_ALTITUDE")               ? eSupportedGADShapes::POINT_ALTITUDE :
         (s == "POINT_ALTITUDE_UNCERTAINTY")   ? eSupportedGADShapes::POINT_ALTITUDE_UNCERTAINTY :
         (s == "ELLIPSOID_ARC")                ? eSupportedGADShapes::ELLIPSOID_ARC :
               eSupportedGADShapes::INVALID;
}

void SupportedGADShapes::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
    utility::string_t namePrefix = prefix;
    if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
    {
        namePrefix += utility::conversions::to_string_t(".");
    }

    multipart->add(ModelBase::toHttpContent(namePrefix,
         m_value == eSupportedGADShapes::POINT                       ? utility::conversions::to_string_t("POINT") :
         m_value == eSupportedGADShapes::POINT_UNCERTAINTY_CIRCLE    ? utility::conversions::to_string_t("POINT_UNCERTAINTY_CIRCLE") :
         m_value == eSupportedGADShapes::POINT_UNCERTAINTY_ELLIPSE   ? utility::conversions::to_string_t("POINT_UNCERTAINTY_ELLIPSE") :
         m_value == eSupportedGADShapes::POLYGON                     ? utility::conversions::to_string_t("POLYGON") :
         m_value == eSupportedGADShapes::POINT_ALTITUDE              ? utility::conversions::to_string_t("POINT_ALTITUDE") :
         m_value == eSupportedGADShapes::POINT_ALTITUDE_UNCERTAINTY  ? utility::conversions::to_string_t("POINT_ALTITUDE_UNCERTAINTY") :
         m_value == eSupportedGADShapes::ELLIPSOID_ARC               ? utility::conversions::to_string_t("ELLIPSOID_ARC") :
                                                                       utility::conversions::to_string_t("INVALID")
    ));
}

void SupportedGADShapes::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
    utility::string_t namePrefix = prefix;
    if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
    {
        namePrefix += utility::conversions::to_string_t(".");
    }

    {
       utility::string_t s;
       s = ModelBase::stringFromHttpContent(multipart->getContent(namePrefix));
       setValue(
            (s == "POINT")                         ? eSupportedGADShapes::POINT :
            (s == "POINT_UNCERTAINTY_CIRCLE")      ? eSupportedGADShapes::POINT_UNCERTAINTY_CIRCLE :
            (s == "POINT_UNCERTAINTY_ELLIPSE")     ? eSupportedGADShapes::POINT_UNCERTAINTY_ELLIPSE :
            (s == "POLYGON")                       ? eSupportedGADShapes::POLYGON :
            (s == "POINT_ALTITUDE")                ? eSupportedGADShapes::POINT_ALTITUDE :
            (s == "POINT_ALTITUDE_UNCERTAINTY")    ? eSupportedGADShapes::POINT_ALTITUDE_UNCERTAINTY :
            (s == "ELLIPSOID_ARC")                 ? eSupportedGADShapes::ELLIPSOID_ARC :
                                                     eSupportedGADShapes::INVALID
      );
    }
}

SupportedGADShapes::eSupportedGADShapes SupportedGADShapes::getValue() const
{
   return m_value;
}

void SupportedGADShapes::setValue(SupportedGADShapes::eSupportedGADShapes const value)
{
   m_value = value;
}
...
Assignee
Assign to
Time tracking