forked from loafle/openapi-generator-original
[java] Add licenseName and licenseUrl options.
This commit is contained in:
committed by
wing328
parent
7fc8b24001
commit
3bc3a40073
@@ -25,12 +25,18 @@ public class CodegenConstants {
|
||||
public static final String ARTIFACT_VERSION = "artifactVersion";
|
||||
public static final String ARTIFACT_VERSION_DESC = "artifact version in generated pom.xml";
|
||||
|
||||
public static final String LICENSE_NAME = "licenseName";
|
||||
public static final String LICENSE_NAME_DESC = "The name of the license";
|
||||
|
||||
public static final String LICENSE_URL = "licenseUrl";
|
||||
public static final String LICENSE_URL_DESC = "The URL of the license";
|
||||
|
||||
public static final String SOURCE_FOLDER = "sourceFolder";
|
||||
public static final String SOURCE_FOLDER_DESC = "source folder for generated code";
|
||||
|
||||
public static final String IMPL_FOLDER = "implFolder";
|
||||
public static final String IMPL_FOLDER_DESC = "folder for generated implementation code";
|
||||
|
||||
|
||||
public static final String LOCAL_VARIABLE_PREFIX = "localVariablePrefix";
|
||||
public static final String LOCAL_VARIABLE_PREFIX_DESC = "prefix for generated code members and local variables";
|
||||
|
||||
@@ -48,13 +54,13 @@ public class CodegenConstants {
|
||||
|
||||
public static final String USE_DATETIME_OFFSET = "useDateTimeOffset";
|
||||
public static final String USE_DATETIME_OFFSET_DESC = "Use DateTimeOffset to model date-time properties";
|
||||
|
||||
|
||||
public static final String ENSURE_UNIQUE_PARAMS = "ensureUniqueParams";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_DESC = "Whether to ensure parameter names are unique in an operation (rename parameters that are not).";
|
||||
|
||||
public static final String PACKAGE_NAME = "packageName";
|
||||
public static final String PACKAGE_VERSION = "packageVersion";
|
||||
|
||||
|
||||
public static final String PACKAGE_TITLE = "packageTitle";
|
||||
public static final String PACKAGE_TITLE_DESC = "Specifies an AssemblyTitle for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
public static final String PACKAGE_PRODUCTNAME = "packageProductName";
|
||||
@@ -65,7 +71,7 @@ public class CodegenConstants {
|
||||
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_COPYRIGHT = "packageCopyright";
|
||||
public static final String PACKAGE_COPYRIGHT_DESC = "Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
|
||||
|
||||
|
||||
public static final String POD_VERSION = "podVersion";
|
||||
|
||||
public static final String OPTIONAL_METHOD_ARGUMENT = "optionalMethodArgument";
|
||||
@@ -79,13 +85,13 @@ public class CodegenConstants {
|
||||
|
||||
public static final String RETURN_ICOLLECTION = "returnICollection";
|
||||
public static final String RETURN_ICOLLECTION_DESC = "Return ICollection<T> instead of the concrete type.";
|
||||
|
||||
|
||||
public static final String OPTIONAL_PROJECT_FILE = "optionalProjectFile";
|
||||
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate {PackageName}.csproj.";
|
||||
|
||||
|
||||
public static final String OPTIONAL_PROJECT_GUID = "packageGuid";
|
||||
public static final String OPTIONAL_PROJECT_GUID_DESC = "The GUID that will be associated with the C# project";
|
||||
|
||||
|
||||
public static final String MODEL_PROPERTY_NAMING = "modelPropertyNaming";
|
||||
public static final String MODEL_PROPERTY_NAMING_DESC = "Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name";
|
||||
|
||||
@@ -132,5 +138,4 @@ public class CodegenConstants {
|
||||
|
||||
public static final String GENERATE_PROPERTY_CHANGED = "generatePropertyChanged";
|
||||
public static final String GENERATE_PROPERTY_CHANGED_DESC = "Specifies that models support raising property changed events.";
|
||||
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-java";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String licenseName = "Apache License, Version 2.0";
|
||||
protected String licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0";
|
||||
protected String projectFolder = "src" + File.separator + "main";
|
||||
protected String projectTestFolder = "src" + File.separator + "test";
|
||||
protected String sourceFolder = projectFolder + File.separator + "java";
|
||||
@@ -117,6 +119,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.LICENSE_NAME, CodegenConstants.LICENSE_NAME_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.LICENSE_URL, CodegenConstants.LICENSE_URL_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC));
|
||||
@@ -187,6 +191,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.LICENSE_NAME)) {
|
||||
this.setLicenseName((String) additionalProperties.get(CodegenConstants.LICENSE_NAME));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.LICENSE_NAME, licenseName);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.LICENSE_URL)) {
|
||||
this.setLicenseUrl((String) additionalProperties.get(CodegenConstants.LICENSE_URL));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.LICENSE_URL, licenseUrl);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
}
|
||||
@@ -821,7 +837,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
op.path = sanitizePath(op.path);
|
||||
return op;
|
||||
}
|
||||
|
||||
|
||||
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
|
||||
// This generator uses inline classes to define enums, which breaks when
|
||||
// dealing with models that have subTypes. To clean this up, we will analyze
|
||||
@@ -895,6 +911,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.artifactVersion = artifactVersion;
|
||||
}
|
||||
|
||||
public void setLicenseName(String licenseName) {
|
||||
this.licenseName = licenseName;
|
||||
}
|
||||
|
||||
public void setLicenseUrl(String licenseUrl) {
|
||||
this.licenseUrl = licenseUrl;
|
||||
}
|
||||
|
||||
public void setSourceFolder(String sourceFolder) {
|
||||
this.sourceFolder = sourceFolder;
|
||||
}
|
||||
@@ -957,7 +981,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public void setSupportJava6(boolean value) {
|
||||
this.supportJava6 = value;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -131,7 +139,7 @@
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
{{#useBeanValidation}}
|
||||
{{#useBeanValidation}}
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
@@ -139,8 +147,8 @@
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
{{#performBeanValidation}}
|
||||
{{/useBeanValidation}}
|
||||
{{#performBeanValidation}}
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
@@ -153,7 +161,6 @@
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/performBeanValidation}}
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@@ -174,4 +181,4 @@
|
||||
<junit-version>4.12</junit-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -194,7 +202,7 @@
|
||||
<version>${commons_io_version}</version>
|
||||
</dependency>
|
||||
{{/supportJava6}}
|
||||
{{#useBeanValidation}}
|
||||
{{#useBeanValidation}}
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
@@ -202,7 +210,7 @@
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
{{/useBeanValidation}}
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<directory>target</directory>
|
||||
@@ -117,4 +125,4 @@
|
||||
<junit-version>4.8.2</junit-version>
|
||||
<slf4j-version>1.6.3</slf4j-version>
|
||||
</properties>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -5,6 +5,15 @@
|
||||
<packaging>jar</packaging>
|
||||
<name>{{artifactId}}</name>
|
||||
<version>{{artifactVersion}}</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
|
||||
@@ -32,36 +32,38 @@ public class JavaClientOptionsTest extends AbstractOptionsTest {
|
||||
@Override
|
||||
protected void setExpectations() {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setModelPackage(JavaClientOptionsProvider.MODEL_PACKAGE_VALUE);
|
||||
clientCodegen.setModelPackage(JavaClientOptionsProvider.MODEL_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setApiPackage(JavaClientOptionsProvider.API_PACKAGE_VALUE);
|
||||
clientCodegen.setApiPackage(JavaClientOptionsProvider.API_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(JavaClientOptionsProvider.SORT_PARAMS_VALUE));
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(JavaClientOptionsProvider.SORT_PARAMS_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setInvokerPackage(JavaClientOptionsProvider.INVOKER_PACKAGE_VALUE);
|
||||
clientCodegen.setInvokerPackage(JavaClientOptionsProvider.INVOKER_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGroupId(JavaClientOptionsProvider.GROUP_ID_VALUE);
|
||||
clientCodegen.setGroupId(JavaClientOptionsProvider.GROUP_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactId(JavaClientOptionsProvider.ARTIFACT_ID_VALUE);
|
||||
clientCodegen.setArtifactId(JavaClientOptionsProvider.ARTIFACT_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactVersion(JavaClientOptionsProvider.ARTIFACT_VERSION_VALUE);
|
||||
clientCodegen.setArtifactVersion(JavaClientOptionsProvider.ARTIFACT_VERSION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSourceFolder(JavaClientOptionsProvider.SOURCE_FOLDER_VALUE);
|
||||
clientCodegen.setLicenseName(JavaOptionsProvider.LICENSE_NAME_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setLocalVariablePrefix(JavaClientOptionsProvider.LOCAL_PREFIX_VALUE);
|
||||
clientCodegen.setLicenseUrl(JavaOptionsProvider.LICENSE_URL_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSerializableModel(Boolean.valueOf(JavaClientOptionsProvider.SERIALIZABLE_MODEL_VALUE));
|
||||
clientCodegen.setSourceFolder(JavaOptionsProvider.SOURCE_FOLDER_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setLocalVariablePrefix(JavaClientOptionsProvider.LOCAL_PREFIX_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSerializableModel(Boolean.valueOf(JavaClientOptionsProvider.SERIALIZABLE_MODEL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setLibrary(JavaClientOptionsProvider.DEFAULT_LIBRARY_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setFullJavaUtil(Boolean.valueOf(JavaClientOptionsProvider.FULL_JAVA_UTIL_VALUE));
|
||||
clientCodegen.setFullJavaUtil(Boolean.valueOf(JavaClientOptionsProvider.FULL_JAVA_UTIL_VALUE));
|
||||
times = 1;
|
||||
// clientCodegen.setSupportJava6(Boolean.valueOf(JavaClientOptionsProvider.SUPPORT_JAVA6));
|
||||
//times = 1;
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(JavaClientOptionsProvider.USE_BEANVALIDATION));
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(JavaClientOptionsProvider.USE_BEANVALIDATION));
|
||||
times = 1;
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(JavaClientOptionsProvider.PERFORM_BEANVALIDATION));
|
||||
times = 1;
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(JavaClientOptionsProvider.PERFORM_BEANVALIDATION));
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ public class JavaOptionsProvider implements OptionsProvider {
|
||||
public static final String MODEL_PACKAGE_VALUE = "package";
|
||||
public static final String API_PACKAGE_VALUE = "apiPackage";
|
||||
public static final String INVOKER_PACKAGE_VALUE = "io.swagger.client.test";
|
||||
public static final String LICENSE_NAME_VALUE = "Apache License, Version 2.0";
|
||||
public static final String LICENSE_URL_VALUE = "http://www.apache.org/licenses/LICENSE-2.0";
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String GROUP_ID_VALUE = "io.swagger.test";
|
||||
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
|
||||
@@ -37,6 +39,8 @@ public class JavaOptionsProvider implements OptionsProvider {
|
||||
.put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
|
||||
.put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
|
||||
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
|
||||
.put(CodegenConstants.LICENSE_NAME, LICENSE_NAME_VALUE)
|
||||
.put(CodegenConstants.LICENSE_URL, LICENSE_URL_VALUE)
|
||||
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
|
||||
.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, LOCAL_PREFIX_VALUE)
|
||||
.put(CodegenConstants.SERIALIZABLE_MODEL, SERIALIZABLE_MODEL_VALUE)
|
||||
|
||||
@@ -14,6 +14,8 @@ public class JaxRSServerOptionsProvider implements OptionsProvider {
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String GROUP_ID_VALUE = "io.swagger.test";
|
||||
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
|
||||
public static final String LICENSE_NAME_VALUE = "Apache License, Version 2.0";
|
||||
public static final String LICENSE_URL_VALUE = "http://www.apache.org/licenses/LICENSE-2.0";
|
||||
public static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
|
||||
public static final String LOCAL_PREFIX_VALUE = "tst";
|
||||
public static final String DEFAULT_LIBRARY_VALUE = "jersey2";
|
||||
@@ -49,6 +51,8 @@ public class JaxRSServerOptionsProvider implements OptionsProvider {
|
||||
.put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
|
||||
.put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
|
||||
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
|
||||
.put(CodegenConstants.LICENSE_NAME, LICENSE_NAME_VALUE)
|
||||
.put(CodegenConstants.LICENSE_URL, LICENSE_URL_VALUE)
|
||||
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
|
||||
.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, LOCAL_PREFIX_VALUE)
|
||||
.put(CodegenConstants.SERIALIZABLE_MODEL, SERIALIZABLE_MODEL_VALUE)
|
||||
|
||||
Reference in New Issue
Block a user