openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [Elm] Asterisks being allowed in Custom Types (from enums)

Open Erudition opened this issue 3 years ago • 0 comments

Bug Report Checklist

  • [X] Have you provided a full/minimal spec to reproduce the issue?
  • Using the full Stripe API spec.

  • [X] Have you validated the input using an OpenAPI validator (example)?
  • I used the CLI with validate and it found no issues.

  • [x] Have you tested with the latest master to confirm the issue still exists?
  • Yes

  • [X] Have you searched for related issues/PRs?
  • [X] What's the actual output vs expected output?
Description
openapi-generator version

Latest master

OpenAPI declaration file content or url

https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json

Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate    -i https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json    -g elm    -o ./elm-stripeFix

Puts out the invalid code:

type EnabledEvents
    = EnabledEvents*
    | EnabledEventsAccountApplicationAuthorized
    | EnabledEventsAccountApplicationDeauthorized
    | EnabledEventsAccountExternalAccountCreated
    | EnabledEventsAccountExternalAccountDeleted
    | -- ...

But asterisks are not valid in elm identifiers.

Suggest a fix

Replace with Underscore, if using the same name is truly needed. Otherwise, pick a more descriptive name.

For example, in this case the * value seems to mean "all", so EnabledEventsAll would be ideal.

(That said, I wish these types were all in their own modules, so we could just use qualified names like EnabledEvents.All rather than having long prefixes on every value)

Erudition avatar Oct 10 '22 04:10 Erudition