Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[all] add "x-enum-varnames" extension to control enum varname#917

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jmini merged 2 commits intoOpenAPITools:masterfromosjupiter:feature/xenumname
Aug 30, 2018

Conversation

@osjupiter
Copy link
Contributor

PR checklist

  • Read thecontribution guidelines.
  • Ran the shell script under./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\.
  • Filed the PR against thecorrect branch:master,3.3.x,4.0.x. Default:master.
  • Copied thetechnical committee to review the pull request if your PR is targeting a particular programming language.

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.

strobox reacted with thumbs up emoji
privatevoidupdateEnumVarsWithExtensions(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()) {
Copy link
Member

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:stringenum:          -a          -b          -cx-enum-varnames:          -FOO          -BAR

Copy link
ContributorAuthor

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.

jmini reacted with thumbs up emoji
@jminijmini mentioned this pull requestAug 29, 2018
@jminijmini changed the titleadd "x-enum-varnames" extension to control enum varname[all] add "x-enum-varnames" extension to control enum varnameAug 30, 2018
@jminijmini added this to the3.2.3 milestoneAug 30, 2018
@jmini
Copy link
Member

Tested with a java client generator with:

EnumWithCustomName:type:integerformat:int32enum:        -1        -2x-enum-varnames:        -FOO        -BAR

The produced codeEnumWithCustomName.java looks good.

strobox reacted with thumbs up emoji

@jminijmini merged commit62abd51 intoOpenAPITools:masterAug 30, 2018
@jmini
Copy link
Member

Thank you for this great contribution!

@wing328
Copy link
Member

@osjupiter thanks for the PR, which has been included in the v3.2.3 release:https://twitter.com/oas_generator/status/1035200785066254336

jmini added a commit to jmini/openapi-experiments that referenced this pull requestSep 1, 2018
@phstudy
Copy link
Contributor

phstudy commentedSep 26, 2018
edited
Loading

The codegen ofinteger type enum model works fine. However, If I reference theinteger type enum in other model, it always will be treat as a outer class enum.

This issue was fixed in#1120.

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull requestFeb 27, 2019
…ITools#917)* add "x-enum-varnames" extension to control the naming of the enum parameter name* allow to set different size from target enum
@akhileshnair08
Copy link

akhileshnair08 commentedAug 4, 2020
edited
Loading

ABCEnum:
enum:
-{0,"aum"}
-{1,"gautham"}
-{2,"Buddha"}
x-enum-varnames:
- AUM
- GAUTHAM
- BUDDHA
type: object
properties:
num_value:
type: integer
format: int32
str_value:
type: string

Why is this not working???
getting below error:
unexpected error in Open-API generation (org.openapitools:openapi-generator-maven-plugin:4.1.3:generate:default:generate-sources)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jminijminijmini approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.2.3

Development

Successfully merging this pull request may close these issues.

5 participants

@osjupiter@jmini@wing328@phstudy@akhileshnair08

[8]ページ先頭

©2009-2025 Movatter.jp