forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
@@ -107,6 +107,8 @@ public class CodegenConstants {
|
||||
public static final String PACKAGE_DESCRIPTION_DESC = "Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
public static final String PACKAGE_COMPANY = "packageCompany";
|
||||
public static final String PACKAGE_COMPANY_DESC = "Specifies an AssemblyCompany for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
public static final String PACKAGE_AUTHORS = "packageAuthors";
|
||||
public static final String PACKAGE_AUTHORS_DESC = "Specifies Authors property in the .NET Core project file.";
|
||||
public static final String PACKAGE_COPYRIGHT = "packageCopyright";
|
||||
public static final String PACKAGE_COPYRIGHT_DESC = "Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
|
||||
@@ -118,6 +120,9 @@ public class CodegenConstants {
|
||||
public static final String OPTIONAL_ASSEMBLY_INFO = "optionalAssemblyInfo";
|
||||
public static final String OPTIONAL_ASSEMBLY_INFO_DESC = "Generate AssemblyInfo.cs.";
|
||||
|
||||
public static final String NETCORE_PROJECT_FILE = "netCoreProjectFile";
|
||||
public static final String NETCORE_PROJECT_FILE_DESC = "Use the new format (.NET Core) for .NET project files (.csproj).";
|
||||
|
||||
public static final String USE_COLLECTION = "useCollection";
|
||||
public static final String USE_COLLECTION_DESC = "Deserialize array types to Collection<T> instead of List<T>.";
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
LOGGER.error("Missing required field info version. Default appVersion set to 1.0.0");
|
||||
config.additionalProperties().put("appVersion", "1.0.0");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(info.getDescription())) {
|
||||
// set a default description if none if provided
|
||||
config.additionalProperties().put("appDescription",
|
||||
|
||||
@@ -18,6 +18,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
protected boolean useDateTimeOffsetFlag = false;
|
||||
protected boolean useCollection = false;
|
||||
protected boolean returnICollection = false;
|
||||
protected boolean netCoreProjectFileFlag = false;
|
||||
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String packageName = "IO.Swagger";
|
||||
@@ -26,6 +27,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
protected String packageDescription = "A library generated from a Swagger doc";
|
||||
protected String packageCompany = "Swagger";
|
||||
protected String packageCopyright = "No Copyright";
|
||||
protected String packageAuthors = "Swagger";
|
||||
|
||||
protected String interfacePrefix = "I";
|
||||
|
||||
@@ -161,6 +163,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
this.optionalMethodArgumentFlag = flag;
|
||||
}
|
||||
|
||||
public void setNetCoreProjectFileFlag(boolean flag) {
|
||||
this.netCoreProjectFileFlag = flag;
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null) option.defaultValue(defaultValue);
|
||||
@@ -238,6 +244,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_COPYRIGHT, packageCopyright);
|
||||
}
|
||||
|
||||
// {{packageAuthors}}
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_AUTHORS)) {
|
||||
setPackageAuthors((String) additionalProperties.get(CodegenConstants.PACKAGE_AUTHORS));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_AUTHORS, packageAuthors);
|
||||
}
|
||||
|
||||
// {{useDateTimeOffset}}
|
||||
if (additionalProperties.containsKey(CodegenConstants.USE_DATETIME_OFFSET)) {
|
||||
@@ -257,6 +270,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
setOptionalEmitDefaultValue(Boolean.valueOf(additionalProperties.get(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) {
|
||||
setNetCoreProjectFileFlag(Boolean.valueOf(additionalProperties.get(CodegenConstants.NETCORE_PROJECT_FILE).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INTERFACE_PREFIX)) {
|
||||
String useInterfacePrefix = additionalProperties.get(CodegenConstants.INTERFACE_PREFIX).toString();
|
||||
if("false".equals(useInterfacePrefix.toLowerCase())) {
|
||||
@@ -632,6 +649,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
public void setPackageCopyright(String packageCopyright) {
|
||||
this.packageCopyright = packageCopyright;
|
||||
}
|
||||
|
||||
public void setPackageAuthors(String packageAuthors) {
|
||||
this.packageAuthors = packageAuthors;
|
||||
}
|
||||
|
||||
public void setSourceFolder(String sourceFolder) {
|
||||
this.sourceFolder = sourceFolder;
|
||||
|
||||
@@ -178,6 +178,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("integer", "integer");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("binary", "binary");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
/**
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
|
||||
@@ -151,6 +151,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC,
|
||||
this.allowUnicodeIdentifiers);
|
||||
|
||||
addSwitch(CodegenConstants.NETCORE_PROJECT_FILE,
|
||||
CodegenConstants.NETCORE_PROJECT_FILE_DESC,
|
||||
this.netCoreProjectFileFlag);
|
||||
|
||||
regexModifiers = new HashMap<Character, String>();
|
||||
regexModifiers.put('i', "IgnoreCase");
|
||||
regexModifiers.put('m', "Multiline");
|
||||
@@ -239,6 +243,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is only supported by generated code for .NET 4+.");
|
||||
} else if(NETSTANDARD.equals(targetFramework)) {
|
||||
LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is not supported in .NET Standard generated code.");
|
||||
} else if(Boolean.TRUE.equals(netCoreProjectFileFlag)) {
|
||||
LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is not supported in .NET Core csproj project format.");
|
||||
} else {
|
||||
setGeneratePropertyChanged(Boolean.valueOf(additionalProperties.get(CodegenConstants.GENERATE_PROPERTY_CHANGED).toString()));
|
||||
}
|
||||
@@ -303,7 +309,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
clientPackageDir, "ApiResponse.cs"));
|
||||
supportingFiles.add(new SupportingFile("ExceptionFactory.mustache",
|
||||
clientPackageDir, "ExceptionFactory.cs"));
|
||||
if(Boolean.FALSE.equals(this.netStandard)) {
|
||||
if(Boolean.FALSE.equals(this.netStandard) && Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "build.bat"));
|
||||
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "build.sh"));
|
||||
|
||||
@@ -311,7 +317,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
supportingFiles.add(new SupportingFile("packages.config.mustache", packageFolder + File.separator, "packages.config"));
|
||||
// .travis.yml for travis-ci.org CI
|
||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||
} else {
|
||||
} else if(Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
||||
supportingFiles.add(new SupportingFile("project.json.mustache", packageFolder + File.separator, "project.json"));
|
||||
}
|
||||
|
||||
@@ -323,7 +329,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".cs");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".cs");
|
||||
|
||||
supportingFiles.add(new SupportingFile("packages_test.config.mustache", testPackageFolder + File.separator, "packages.config"));
|
||||
if (Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
||||
supportingFiles.add(new SupportingFile("packages_test.config.mustache", testPackageFolder + File.separator, "packages.config"));
|
||||
}
|
||||
}
|
||||
|
||||
if(Boolean.TRUE.equals(generatePropertyChanged)) {
|
||||
@@ -337,19 +345,28 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// UPDATE (20160612) no longer needed as the Apache v2 LICENSE is added globally
|
||||
//supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
|
||||
|
||||
if (optionalAssemblyInfoFlag) {
|
||||
if (optionalAssemblyInfoFlag && Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
||||
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs"));
|
||||
}
|
||||
if (optionalProjectFileFlag) {
|
||||
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
||||
supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, packageName + ".csproj"));
|
||||
if(Boolean.FALSE.equals(this.netStandard)) {
|
||||
supportingFiles.add(new SupportingFile("nuspec.mustache", packageFolder, packageName + ".nuspec"));
|
||||
|
||||
if(Boolean.TRUE.equals(this.netCoreProjectFileFlag)) {
|
||||
supportingFiles.add(new SupportingFile("netcore_project.mustache", packageFolder, packageName + ".csproj"));
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, packageName + ".csproj"));
|
||||
if(Boolean.FALSE.equals(this.netStandard)) {
|
||||
supportingFiles.add(new SupportingFile("nuspec.mustache", packageFolder, packageName + ".nuspec"));
|
||||
}
|
||||
}
|
||||
|
||||
if(Boolean.FALSE.equals(excludeTests)) {
|
||||
// NOTE: This exists here rather than previous excludeTests block because the test project is considered an optional project file.
|
||||
supportingFiles.add(new SupportingFile("TestProject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
||||
if(Boolean.TRUE.equals(this.netCoreProjectFileFlag)) {
|
||||
supportingFiles.add(new SupportingFile("netcore_testproject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("TestProject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ public class CppRestClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("binary", "std::string");
|
||||
typeMapping.put("number", "double");
|
||||
typeMapping.put("UUID", "utility::string_t");
|
||||
|
||||
super.importMapping = new HashMap<String, String>();
|
||||
importMapping.put("std::vector", "#include <vector>");
|
||||
|
||||
@@ -86,6 +86,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("File", "MultipartFile");
|
||||
typeMapping.put("UUID", "String");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
@@ -63,6 +63,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("file", "File");
|
||||
typeMapping.put("UUID", "String");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
@@ -67,6 +67,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
||||
typeMapping.put("DateTime", "datetime");
|
||||
typeMapping.put("object", "object");
|
||||
typeMapping.put("file", "file");
|
||||
typeMapping.put("UUID", "str");
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/connexion";
|
||||
|
||||
@@ -129,6 +129,7 @@ public class GoServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("object", "interface{}");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("time.Time", "time");
|
||||
|
||||
@@ -145,6 +145,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
typeMapping.put("number", "Double");
|
||||
typeMapping.put("integer", "Int");
|
||||
typeMapping.put("any", "Value");
|
||||
typeMapping.put("UUID", "Text");
|
||||
|
||||
importMapping.clear();
|
||||
importMapping.put("Map", "qualified Data.Map as Map");
|
||||
|
||||
@@ -126,6 +126,11 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "QString");
|
||||
typeMapping.put("ByteArray", "QByteArray");
|
||||
// UUID support - possible enhancement : use QUuid instead of QString.
|
||||
// beware though that Serialisation/deserialisation of QUuid does not
|
||||
// come out of the box and will need to be sorted out (at least imply
|
||||
// modifications on multiple templates)
|
||||
typeMapping.put("UUID", "QString");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
// remove modelPackage and apiPackage added by default
|
||||
cliOptions.clear();
|
||||
|
||||
@@ -95,6 +95,7 @@ public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("file", "std::string");
|
||||
typeMapping.put("DateTime", "std::string");
|
||||
typeMapping.put("Date", "std::string");
|
||||
typeMapping.put("UUID", "std::string");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user