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] [PHP] Enum values starting with - have the same name as ones without, resolving in duplicate consts #7441

Open
5 of 6 tasks
victorlap opened this issue Sep 17, 2020 · 0 comments

Comments

@victorlap
Copy link

victorlap commented Sep 17, 2020

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

Currently enum values that are the same except for a starting - result in the same const names for php model files. This result in unexecutable files, that need manual editing before it can be used.

openapi-generator version

both on docker:
openapi-generator-cli 5.0.0-SNAPSHOT
commit : a28037d
built : 2020-09-01T09:02:56Z
openapi-generator-cli 5.0.0-beta2
commit : 212b4f7
built : 2020-09-04T05:08:30Z

OpenAPI declaration file content or url

https://gist.github.com/victorlap/44e351b72f5d9f26f0ac1943b4c6cf22

Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v5.0.0-beta2 generate \
    -i /local/spec.json \
    -g php \
    -o /local/src
Steps to reproduce

Run the above command on the spec that is linked in the gist.
Check file src/lib/Model/SalesOrderBillingaddress.php and see duplicate const declaration:

    const CUSTOM_FORM__1049 = '-1049';
    const CUSTOM_FORM__1049 = '1049';
Related issues/PRs

I've not found any related issues/PRs

Suggest a fix/enhancement

I think the sanitizing of the name needs to change a bit.

It's probably somewhere in the toEnumVarName

@victorlap victorlap changed the title [BUG] Description [BUG] [PHP] Enum values starting with - have the same name as ones without, resolving in duplicate consts Sep 17, 2020
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