mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-19 06:19:20 +00:00
[Golang][client] Add option for standard Go generated code comment (#555)
* update go generated code comment * update samples for go petstore * update code generation comment * update samples for go petstore * Trigger CI due to previous Shippable race condition * add -DwithGoCodegenComment=true option * reset samples * add withGoCodegenComment=true to bin/go-petstore-withxml.sh * update samples/.../go-petstore-withXml using -DwithGoCodegenComment=true
This commit is contained in:
@@ -56,6 +56,9 @@ public class CodegenConstants {
|
||||
public static final String PYTHON_PACKAGE_NAME = "pythonPackageName";
|
||||
public static final String PYTHON_PACKAGE_NAME_DESC = "package name for generated python code";
|
||||
|
||||
public static final String WITH_GO_CODEGEN_COMMENT = "withGoCodegenComment";
|
||||
public static final String WITH_GO_CODEGEN_COMMENT_DESC = "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs";
|
||||
|
||||
public static final String GROUP_ID = "groupId";
|
||||
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGoCodegen.class);
|
||||
|
||||
protected boolean withGoCodegenComment = false;
|
||||
protected boolean withXml = false;
|
||||
|
||||
protected String packageName = "openapi";
|
||||
@@ -584,6 +585,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
}
|
||||
|
||||
public void setWithGoCodegenComment(boolean withGoCodegenComment) {
|
||||
this.withGoCodegenComment = withGoCodegenComment;
|
||||
}
|
||||
|
||||
public void setWithXml(boolean withXml) {
|
||||
this.withXml = withXml;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
public static final String WITH_GO_CODEGEN_COMMENT = "withGoCodegenComment";
|
||||
public static final String WITH_XML = "withXml";
|
||||
|
||||
public GoClientCodegen() {
|
||||
@@ -49,8 +50,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_GO_CODEGEN_COMMENT, "whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs"));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
|
||||
|
||||
|
||||
// option to change the order of form/body parameter
|
||||
cliOptions.add(CliOption.newBoolean(
|
||||
CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS,
|
||||
@@ -93,6 +96,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
supportingFiles.add(new SupportingFile("response.mustache", "", "response.go"));
|
||||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
|
||||
if (additionalProperties.containsKey(WITH_GO_CODEGEN_COMMENT)) {
|
||||
setWithGoCodegenComment(Boolean.parseBoolean(additionalProperties.get(WITH_GO_CODEGEN_COMMENT).toString()));
|
||||
if (withGoCodegenComment) {
|
||||
additionalProperties.put(WITH_GO_CODEGEN_COMMENT, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(WITH_XML)) {
|
||||
setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
|
||||
if (withXml) {
|
||||
|
||||
Reference in New Issue
Block a user