[go] Fix: reservedWordsMappings not checked for reserved word (#15083)

* Fix: reservedWordsMappings not checked for reserved word

* Fix coding issue
This commit is contained in:
Ween Jiann 2023-04-11 15:39:53 +08:00 committed by GitHub
parent 8ce990d3d7
commit 81cafdc196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,8 +145,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
"float32", "float64")
);
importMapping = new HashMap<>();
cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
.defaultValue("openapi"));
@ -225,7 +223,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@Override
protected boolean isReservedWord(String word) {
return word != null && reservedWords.contains(word);
return word != null && (reservedWords.contains(word) || reservedWordsMappings().containsKey(word));
}
@Override
@ -407,7 +405,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
String ref = p.get$ref();
String type = null;
String type;
if (ref != null && !ref.isEmpty()) {
type = toModelName(openAPIType);