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
  • #8937
Closed
Open
Issue created Mar 09, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][cpp-restsdk] Enums not generated

Created by: gluttony38

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

A member described with an enum has no corresponding enum when generating code for cpp-restsdk (and it seems to be the same for any C++ generators), it is then hard to map possible values from server to our code, and to ensure not setting an invalid value.

openapi-generator version

5.0.1

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/samples/yaml/pet.yml

Pet status is described with an enum:

status: 
  type: string
  description: pet status in the store
  enum: 
    - available
    - pending
    - sold
Generation Details

Nothing special, but as you can see I use your sample that has the same issue.

Steps to reproduce

Simply generate the code for your sample, you can see in Java there is an enum generated (see https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/Pet.java):

  public enum StatusEnum {
    AVAILABLE("available"),
    
    PENDING("pending"),
    
    SOLD("sold");

    private String value;

    StatusEnum(String value) {
      this.value = value;
    }
    [...]
  }
  [...]
  private StatusEnum status;

But in C++ a direct string is used making it hard to manage cleanly such member (see https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/cpp-restsdk/client/model/Pet.h): utility::string_t m_Status

Related issues/PRs

Found issues for another generator but not for any C++ one.

Suggest a fix

Like in Java, instead of simply using a string, generate an enum and use it as type for such members.

Assignee
Assign to
Time tracking