Skip to content

[BUG][APEX] Enum values can conflict with keywords as Apex is case-insensitive #2616

Open
@arangari

Description

@arangari

Bug Report Checklist

  • [YES ] Have you provided a full/minimal spec to reproduce the issue?

  • [YES] Have you validated the input using an OpenAPI validator (example)?

  • [YES] What's the version of OpenAPI Generator used?

  • [Yes ] Have you search for related issues/PRs?

  • [ YES] What's the actual output vs expected output?

  • [Optional] Bounty to sponsor the fix (example)

Description

take example of a API specifications for CUFX 4.1.
A part of this specs is as below:

"billStatus": {
         "description": " [AHR] omit ",
         "enum": [
           "Due",
           "OverDue",
           "Cancelled",
           "Suspended",
           "Paid",
           "Void",
           "Dispute",
           "PaymentFailed"
         ],
         "type": "string"

The value 'Void' will conflict with keyword 'void'. The generated output is as below:

    public enum BillStatusEnum {
        DUE,
        OVERDUE,
        CANCELLED,
        SUSPENDED,
        PAID,
        VOID,
        DISPUTE,
        PAYMENTFAILED
    }

This issue is continuing from Swagger 2.0 as I tried with that first and then now with OAS3.0.

Also, the maximum enums one can define is 100. This creates the problem in the enums for say Countries.

openapi-generator version

OAS 3.0 (Git Clone at 25d39c3)

OpenAPI declaration file content or url

I am trying to generate client coe for below .
https://app.swaggerhub.com/apis/dlacroix01/CUFX/4.1

Command line used for generation

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ~/Downloads/swagger-client-generated-2/swagger.json -g apex -o ./ClientsApex/CUFX4.1/

Steps to reproduce

After code is generated, try to deploy the code on salesforce org.

Related issues/PRs
Suggest a fix

There can be multiple approaches.

  1. I created class which has constant strings for the enum. The problem is with JSON serialize/deserialize.
  2. using globalpicklist/valueset as these will be useful. However the type-checking cant be performed, as we wouldnt be saving any objects.
    Also there are governor limits [https://help.salesforce.com/articleView?id=fields_creating_global_picklists.htm&type=5]
    We may have to brainstorm here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions