mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-16 15:54:31 +00:00
add cli option to optionally generate assemblyinfo.cs (default: true)
This commit is contained in:
@@ -54,4 +54,9 @@ public class CodegenConstants {
|
||||
public static final String POD_VERSION = "podVersion";
|
||||
|
||||
public static final String OPTIONAL_METHOD_ARGUMENT = "optionalMethodArgument";
|
||||
public static final String OPTIONAL_METHOD_ARGUMENT_DESC = "Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).";
|
||||
|
||||
public static final String OPTIONAL_ASSEMBLY_INFO = "optionalAssemblyInfo";
|
||||
public static final String OPTIONAL_ASSEMBLY_INFO_DESC = "Generate AssemblyInfo.cs (Default: true).";
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||
protected boolean optionalAssemblyInfoFlag = true;
|
||||
protected boolean optionalMethodArgumentFlag = true;
|
||||
protected String packageTitle = "Swagger Library";
|
||||
protected String packageProductName = "SwaggerLibrary";
|
||||
@@ -111,6 +112,8 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "C# Optional method argument, " +
|
||||
"e.g. void square(int x=10) (.net 4.0+ only)."));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.OPTIONAL_ASSEMBLY_INFO,
|
||||
CodegenConstants.OPTIONAL_ASSEMBLY_INFO_DESC).defaultValue(Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,6 +150,11 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
additionalProperties.put("optionalMethodArgument", optionalMethodArgumentFlag);
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_ASSEMBLY_INFO)) {
|
||||
setOptionalAssemblyInfoFlag(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.OPTIONAL_ASSEMBLY_INFO).toString()));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
||||
@@ -159,7 +167,10 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
supportingFiles.add(new SupportingFile("RestSharp.dll", "bin", "RestSharp.dll"));
|
||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", "src" + File.separator + "Properties", "AssemblyInfo.cs"));
|
||||
|
||||
if (optionalAssemblyInfoFlag) {
|
||||
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", "src" + File.separator + "Properties", "AssemblyInfo.cs"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -301,6 +312,10 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
public void setOptionalAssemblyInfoFlag(boolean flag) {
|
||||
this.optionalAssemblyInfoFlag = flag;
|
||||
}
|
||||
|
||||
public void setOptionalMethodArgumentFlag(boolean flag) {
|
||||
this.optionalMethodArgumentFlag = flag;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user