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

Go fix enum numbers #12076

Merged
merged 3 commits into from
Aug 6, 2023
Merged

Conversation

aethanol
Copy link
Contributor

@aethanol aethanol commented Mar 1, 2023

PR checklist

  • Read the contribution 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 the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

fix #11615
Enum vars that start with numbers, but are typed as strings end up starting with a number which is invalid in golang.

Fixes regression introduced in 164d45f#diff-25213c27f6aedea540837be9a27725ec3a402e84b882164ee3f6595f9e2ffaa0L16
Enum consts must be unique across a package, this is solved by the enum name to be suffixed with the class name.

cc: @antihax @wing328 (you were listed as contributors to the go generators)

@aethanol
Copy link
Contributor Author

aethanol commented Aug 6, 2023

bump maybe @HugoMario ?

@@ -486,13 +486,10 @@ public String toEnumVarName(String name, String datatype) {
if ("int".equals(datatype) || "int32".equals(datatype) || "int64".equals(datatype)
|| "uint".equals(datatype) || "uint32".equals(datatype) || "uint64".equals(datatype)
|| "float".equals(datatype) || "float32".equals(datatype) || "float64".equals(datatype)) {
String varName = name;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HugoMario HugoMario merged commit de33c6f into swagger-api:master Aug 6, 2023
8 of 10 checks passed
@HugoMario
Copy link
Contributor

thanks a lot @aethanol !

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

Successfully merging this pull request may close these issues.

[GO] Invalid code generated when enum contains integers
2 participants