forked from loafle/openapi-generator-original
Purge obsolete Go codegen code re github.com/antihax/optional
(#16185)
I spotted a mention of `github.com/antihax/optional` in AbstractGoCodegen. I was curious and investigated. However, it turns out that this code is an obsolete remnant of the go-deprecated generator removed before 6.0.0, so is now just a false lead. This PR cleans it up so no-one else has to go down the same investigative pathway.
This commit is contained in:
parent
a1558e3861
commit
7d6e7e4e75
@ -53,8 +53,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
protected String packageName = "openapi";
|
||||
protected Set<String> numberTypes;
|
||||
|
||||
protected boolean usesOptionals = true;
|
||||
|
||||
public AbstractGoCodegen() {
|
||||
super();
|
||||
|
||||
@ -499,7 +497,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
}
|
||||
|
||||
boolean addedOptionalImport = false;
|
||||
boolean addedTimeImport = false;
|
||||
boolean addedOSImport = false;
|
||||
boolean addedReflectImport = false;
|
||||
@ -516,12 +513,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
addedOSImport = true;
|
||||
}
|
||||
|
||||
// import "time" if the operation has a required time parameter.
|
||||
if (param.required || !usesOptionals) {
|
||||
if (!addedTimeImport && "time.Time".equals(param.dataType)) {
|
||||
imports.add(createMapping("import", "time"));
|
||||
addedTimeImport = true;
|
||||
}
|
||||
// import "time" if the operation has a time parameter.
|
||||
if (!addedTimeImport && "time.Time".equals(param.dataType)) {
|
||||
imports.add(createMapping("import", "time"));
|
||||
addedTimeImport = true;
|
||||
}
|
||||
|
||||
// import "reflect" package if the parameter is collectionFormat=multi
|
||||
@ -530,23 +525,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
addedReflectImport = true;
|
||||
}
|
||||
|
||||
// import "optionals" package if the parameter is optional
|
||||
if (!param.required && usesOptionals) {
|
||||
if (!addedOptionalImport) {
|
||||
imports.add(createMapping("import", "github.com/antihax/optional"));
|
||||
addedOptionalImport = true;
|
||||
}
|
||||
|
||||
// We need to specially map Time type to the optionals package
|
||||
if ("time.Time".equals(param.dataType)) {
|
||||
param.vendorExtensions.put("x-optional-data-type", "Time");
|
||||
} else {
|
||||
// Map optional type to dataType
|
||||
String optionalType = param.dataType.substring(0, 1).toUpperCase(Locale.ROOT) + param.dataType.substring(1);
|
||||
param.vendorExtensions.put("x-optional-data-type", optionalType);
|
||||
}
|
||||
}
|
||||
|
||||
// set x-exportParamName
|
||||
char nameFirstChar = param.paramName.charAt(0);
|
||||
if (Character.isUpperCase(nameFirstChar)) {
|
||||
|
@ -101,7 +101,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
|
||||
outputFolder = "generated-code/go";
|
||||
embeddedTemplateDir = templateDir = "go";
|
||||
usesOptionals = false;
|
||||
|
||||
apiTemplateFiles.put("api.mustache", ".go");
|
||||
modelTemplateFiles.put("model.mustache", ".go");
|
||||
|
Loading…
x
Reference in New Issue
Block a user