-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[all] add "x-enum-varnames" extension to control enum varname #917
Conversation
a16d0ba
to
cfd1f4c
Compare
private void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions) { | ||
if (vendorExtensions != null && vendorExtensions.containsKey("x-enum-varnames")) { | ||
List<String> alias = (List<String>) vendorExtensions.get("x-enum-varnames"); | ||
if (alias.size() == enumVars.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maye you could just log a warning if the sizes do not match.
In my opinion it is OK to still change the first two defined names in a case like this:
EnumProp:
type: string
enum:
- a
- b
- c
x-enum-varnames:
- FOO
- BAR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
Then I'll make changes to allow to set different number of elements from target enum.
Tested with a java client generator with: EnumWithCustomName:
type: integer
format: int32
enum:
- 1
- 2
x-enum-varnames:
- FOO
- BAR The produced code |
Thank you for this great contribution! |
@osjupiter thanks for the PR, which has been included in the v3.2.3 release: https://twitter.com/oas_generator/status/1035200785066254336 |
The codegen of This issue was fixed in #1120. |
…ITools#917) * add "x-enum-varnames" extension to control the naming of the enum parameter name * allow to set different size from target enum
ABCEnum: Why is this not working??? |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.3.x
,4.0.x
. Default:master
.Description of the PR
(details of the change, additional tests that have been done, reference to the issue for tracking, etc)
For issue #893
Add "x-enum-varnames" vendor extension to control names of generated enum properties.