Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
arangari opened this issue Apr 6, 2019 · 2 comments
Open
1 task

Comments

@arangari
Copy link

arangari commented Apr 6, 2019

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.
@auto-labeler
Copy link

auto-labeler bot commented Apr 6, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@arangari
Copy link
Author

arangari commented Apr 6, 2019

can we have example of usage with --reserved-words-mappings.
however, i am not sure if this will help as we want to map say 'void' to 'ahrvoid' , but manage json (de)serialize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant