forked from loafle/openapi-generator-original
better code format in go generators (#11656)
This commit is contained in:
@@ -850,5 +850,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.GO; }
|
||||
public GeneratorLanguage generatorLanguage() {
|
||||
return GeneratorLanguage.GO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
|
||||
// option to change the order of form/body parameter
|
||||
cliOptions.add(CliOption.newBoolean(
|
||||
CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS,
|
||||
CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS_DESC)
|
||||
CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS,
|
||||
CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS_DESC)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false"));
|
||||
@@ -585,7 +585,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
example = "123";
|
||||
}
|
||||
|
||||
return codegenProperty.dataType + "(" + example + ")";
|
||||
return codegenProperty.dataType + "(" + example + ")";
|
||||
}
|
||||
} else {
|
||||
// look up the model
|
||||
|
||||
@@ -150,19 +150,19 @@ public class GoGinServerCodegen extends AbstractGoCodegen {
|
||||
* are available in models, apis, and supporting files
|
||||
*/
|
||||
if (additionalProperties.containsKey("apiVersion")) {
|
||||
this.apiVersion = (String)additionalProperties.get("apiVersion");
|
||||
this.apiVersion = (String) additionalProperties.get("apiVersion");
|
||||
} else {
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("serverPort")) {
|
||||
this.serverPort = Integer.parseInt((String)additionalProperties.get("serverPort"));
|
||||
this.serverPort = Integer.parseInt((String) additionalProperties.get("serverPort"));
|
||||
} else {
|
||||
additionalProperties.put("serverPort", serverPort);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("apiPath")) {
|
||||
this.apiPath = (String)additionalProperties.get("apiPath");
|
||||
this.apiPath = (String) additionalProperties.get("apiPath");
|
||||
} else {
|
||||
additionalProperties.put("apiPath", apiPath);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.*;
|
||||
public class GoServerCodegen extends AbstractGoCodegen {
|
||||
|
||||
/**
|
||||
* Name of additional property for switching routers
|
||||
* Name of additional property for switching routers
|
||||
*/
|
||||
private static final String ROUTER_SWITCH = "router";
|
||||
|
||||
@@ -43,7 +43,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
/**
|
||||
* List of available routers
|
||||
*/
|
||||
private static final String[] ROUTERS = { "mux", "chi" };
|
||||
private static final String[] ROUTERS = {"mux", "chi"};
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(GoServerCodegen.class);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
.defaultValue(sourceFolder));
|
||||
|
||||
CliOption frameworkOption = new CliOption(ROUTER_SWITCH, ROUTER_SWITCH_DESC);
|
||||
for (String option: ROUTERS) {
|
||||
for (String option : ROUTERS) {
|
||||
frameworkOption.addEnum(option, option);
|
||||
}
|
||||
frameworkOption.defaultValue(ROUTERS[0]);
|
||||
@@ -225,7 +225,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
|
||||
final Object propRouter = additionalProperties.get(ROUTER_SWITCH);
|
||||
final Map<String, Boolean> routers = new HashMap<>();
|
||||
for (String router: ROUTERS) {
|
||||
for (String router : ROUTERS) {
|
||||
routers.put(router, router.equals(propRouter));
|
||||
}
|
||||
additionalProperties.put("routers", routers);
|
||||
@@ -244,7 +244,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
supportingFiles.add(new SupportingFile("go.mod.mustache", "", "go.mod"));
|
||||
supportingFiles.add(new SupportingFile("routers.mustache", sourceFolder, "routers.go"));
|
||||
supportingFiles.add(new SupportingFile("logger.mustache", sourceFolder, "logger.go"));
|
||||
supportingFiles.add(new SupportingFile("impl.mustache",sourceFolder, "impl.go"));
|
||||
supportingFiles.add(new SupportingFile("impl.mustache", sourceFolder, "impl.go"));
|
||||
supportingFiles.add(new SupportingFile("helpers.mustache", sourceFolder, "helpers.go"));
|
||||
supportingFiles.add(new SupportingFile("api.mustache", sourceFolder, "api.go"));
|
||||
supportingFiles.add(new SupportingFile("error.mustache", sourceFolder, "error.go"));
|
||||
|
||||
Reference in New Issue
Block a user