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

[REQ] Added enumClassPrefix option to Go server generation #7008

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/generators/go-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sidebar_label: go-server
|packageVersion|Go package version.| |1.0.0|
|serverPort|The network port the generated server binds to| |8080|
|sourceFolder|source folder for generated code| |go|
|enumClassPrefix|Prefix enum with class name| |false|

## IMPORT MAPPING

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public GoServerCodegen() {

/*
* Service templates. You can write services for each Api file with the apiTemplateFiles map.
These services are skeletons built to implement the logic of your api using the
These services are skeletons built to implement the logic of your api using the
expected parameters and response.
*/
apiTemplateFiles.put(
Expand Down Expand Up @@ -185,6 +185,13 @@ public void processOpts() {
additionalProperties.put("featureCORS", corsFeatureEnabled);
}

if (additionalProperties.containsKey(CodegenConstants.ENUM_CLASS_PREFIX)) {
setEnumClassPrefix(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_CLASS_PREFIX).toString()));
if (enumClassPrefix) {
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, true);
}
}

modelPackage = packageName;
apiPackage = packageName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type {{{name}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/form
const (
{{#allowableValues}}
{{#enumVars}}
{{name}} {{{classname}}} = {{{value}}}
{{#enumClassPrefix}}{{{classname.toUpperCase}}}_{{/enumClassPrefix}}{{name}} {{{classname}}} = {{{value}}}
{{/enumVars}}
{{/allowableValues}}
){{/isEnum}}{{^isEnum}}{{#description}}
Expand Down