Merge pull request #1459 from lugaru1234/optionsTestPart2

processOptions tests have been added for Android, Ruby, nodeJS, php, python, csharp, CsharpDotNet2, dart, flash
This commit is contained in:
Tony Tam 2015-10-28 07:22:38 -07:00
commit 29ea8d5501
20 changed files with 657 additions and 116 deletions

View File

@ -40,4 +40,6 @@ public class CodegenConstants {
public static final String SORT_PARAMS_BY_REQUIRED_FLAG = "sortParamsByRequiredFlag";
public static final String SORT_PARAMS_BY_REQUIRED_FLAG_DESC = "Sort method arguments to place required parameters before optional parameters. Default: true";
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_VERSION = "packageVersion";
}

View File

@ -105,7 +105,8 @@ public class DefaultCodegen {
}
if (additionalProperties.containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) {
this.setSortParamsByRequiredFlag(Boolean.valueOf((String)additionalProperties.get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString()));
this.setSortParamsByRequiredFlag(Boolean.valueOf(additionalProperties
.get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString()));
}
}

View File

@ -17,6 +17,7 @@ import java.util.HashSet;
import org.apache.commons.lang.StringUtils;
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String USE_ANDROID_MAVEN_GRADLE_PLUGIN = "useAndroidMavenGradlePlugin";
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-android-client";
@ -64,7 +65,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "artifactId for use in the generated build.gradle and pom.xml"));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "artifact version for use in the generated build.gradle and pom.xml"));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC));
cliOptions.add(new CliOption("useAndroidMavenGradlePlugin", "A flag to toggle android-maven gradle plugin. Default is true."));
cliOptions.add(new CliOption(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin. Default is true."));
}
public CodegenType getTag() {
@ -220,14 +221,15 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
}
if (additionalProperties.containsKey("useAndroidMavenGradlePlugin")) {
this.setUseAndroidMavenGradlePlugin((Boolean) additionalProperties.get("useAndroidMavenGradlePlugin"));
if (additionalProperties.containsKey(USE_ANDROID_MAVEN_GRADLE_PLUGIN)) {
this.setUseAndroidMavenGradlePlugin(Boolean.valueOf((String) additionalProperties
.get(USE_ANDROID_MAVEN_GRADLE_PLUGIN)));
} else {
additionalProperties.put("useAndroidMavenGradlePlugin", useAndroidMavenGradlePlugin);
additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin);
}
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
additionalProperties.put("useAndroidMavenGradlePlugin", useAndroidMavenGradlePlugin);
additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin);
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));

View File

@ -1,6 +1,7 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@ -79,8 +80,8 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("object", "Object");
cliOptions.clear();
cliOptions.add(new CliOption("packageName", "C# package name (convention: Camel.Case), default: IO.Swagger"));
cliOptions.add(new CliOption("packageVersion", "C# package version, default: 1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name (convention: Camel.Case), default: IO.Swagger"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version, default: 1.0.0"));
}
@ -88,19 +89,19 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("packageVersion")) {
packageVersion = (String) additionalProperties.get("packageVersion");
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
additionalProperties.put("packageVersion", packageVersion);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
}
if (additionalProperties.containsKey("packageName")) {
packageName = (String) additionalProperties.get("packageName");
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
apiPackage = packageName + ".Api";
modelPackage = packageName + ".Model";
clientPackage = packageName + ".Client";
} else {
additionalProperties.put("packageName", packageName);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
}
additionalProperties.put("clientPackage", clientPackage);
@ -252,4 +253,11 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
return camelize(sanitizeName(operationId));
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}
}

View File

@ -1,6 +1,7 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@ -15,6 +16,7 @@ import java.util.HashMap;
import java.util.HashSet;
public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String CLIENT_PACKAGE = "clientPackage";
protected String packageName = "IO.Swagger";
protected String packageVersion = "1.0.0";
protected String clientPackage = "IO.Swagger.Client";
@ -77,34 +79,34 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
typeMapping.put("object", "Object");
cliOptions.clear();
cliOptions.add(new CliOption("packageName", "C# package name (convention: Camel.Case), default: IO.Swagger"));
cliOptions.add(new CliOption("packageVersion", "C# package version, default: 1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name (convention: Camel.Case), default: IO.Swagger"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version, default: 1.0.0"));
cliOptions.add(new CliOption(CLIENT_PACKAGE, "C# client package name (convention: Camel.Case), default: IO.Swagger.Client"));
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("packageVersion")) {
packageVersion = (String) additionalProperties.get("packageVersion");
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
additionalProperties.put("packageVersion", packageVersion);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
}
if (additionalProperties.containsKey("packageName")) {
packageName = (String) additionalProperties.get("packageName");
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
apiPackage = packageName + ".Api";
modelPackage = packageName + ".Model";
clientPackage = packageName + ".Client";
} else {
additionalProperties.put("packageName", packageName);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
}
if (additionalProperties.containsKey("clientPackage")) {
this.setClientPackage((String) additionalProperties.get("clientPackage"));
if (additionalProperties.containsKey(CLIENT_PACKAGE)) {
this.setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
} else {
additionalProperties.put("clientPackage", clientPackage);
additionalProperties.put(CLIENT_PACKAGE, clientPackage);
}
supportingFiles.add(new SupportingFile("Configuration.mustache",
@ -123,6 +125,14 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
this.clientPackage = clientPackage;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}
public CodegenType getTag() {
return CodegenType.CLIENT;
}

View File

@ -2,6 +2,7 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@ -15,6 +16,10 @@ import java.util.HashSet;
import java.util.HashMap;
public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String BROWSER_CLIENT = "browserClient";
public static final String PUB_NAME = "pubName";
public static final String PUB_VERSION = "pubVersion";
public static final String PUB_DESCRIPTION = "pubDescription";
protected boolean browserClient = true;
protected String pubName = "swagger";
protected String pubVersion = "1.0.0";
@ -72,10 +77,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("date", "DateTime");
typeMapping.put("File", "MultipartFile");
cliOptions.add(new CliOption("browserClient", "Is the client browser based"));
cliOptions.add(new CliOption("pubName", "Name in generated pubspec"));
cliOptions.add(new CliOption("pubVersion", "Version in generated pubspec"));
cliOptions.add(new CliOption("sourceFolder", "source folder for generated code"));
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code"));
}
public CodegenType getTag() {
@ -94,37 +100,37 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("browserClient")) {
this.setBrowserClient(Boolean.parseBoolean((String) additionalProperties.get("browserClient")));
additionalProperties.put("browserClient", browserClient);
if (additionalProperties.containsKey(BROWSER_CLIENT)) {
this.setBrowserClient(Boolean.parseBoolean((String) additionalProperties.get(BROWSER_CLIENT)));
additionalProperties.put(BROWSER_CLIENT, browserClient);
} else {
//not set, use to be passed to template
additionalProperties.put("browserClient", browserClient);
additionalProperties.put(BROWSER_CLIENT, browserClient);
}
if (additionalProperties.containsKey("pubName")) {
this.setPubName((String) additionalProperties.get("pubName"));
if (additionalProperties.containsKey(PUB_NAME)) {
this.setPubName((String) additionalProperties.get(PUB_NAME));
} else {
//not set, use to be passed to template
additionalProperties.put("pubName", pubName);
additionalProperties.put(PUB_NAME, pubName);
}
if (additionalProperties.containsKey("pubVersion")) {
this.setPubVersion((String) additionalProperties.get("pubVersion"));
if (additionalProperties.containsKey(PUB_VERSION)) {
this.setPubVersion((String) additionalProperties.get(PUB_VERSION));
} else {
//not set, use to be passed to template
additionalProperties.put("pubVersion", pubVersion);
additionalProperties.put(PUB_VERSION, pubVersion);
}
if (additionalProperties.containsKey("pubDescription")) {
this.setPubDescription((String) additionalProperties.get("pubDescription"));
if (additionalProperties.containsKey(PUB_DESCRIPTION)) {
this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION));
} else {
//not set, use to be passed to template
additionalProperties.put("pubDescription", pubDescription);
additionalProperties.put(PUB_DESCRIPTION, pubDescription);
}
if (additionalProperties.containsKey("sourceFolder")) {
this.setSourceFolder((String) additionalProperties.get("sourceFolder"));
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
}
final String libFolder = sourceFolder + File.separator + "lib";

View File

@ -68,15 +68,19 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
importMapping.put("File", "flash.filesystem.File");
// from
reservedWords = new HashSet<String>(
Arrays.asList(
"add", "for", "lt", "tellTarget", "and", "function", "ne", "this", "break", "ge", "new", "typeof", "continue", "gt", "not", "var", "delete", "if", "on", "void", "do", "ifFrameLoaded", "onClipEvent", "while", "else", "in", "or", "with", "eq", "le", "return"));
reservedWords = new HashSet<String>(Arrays.asList("add", "for", "lt", "tellTarget", "and",
"function", "ne", "this", "break", "ge", "new", "typeof", "continue", "gt", "not",
"var", "delete", "if", "on", "void", "do", "ifFrameLoaded", "onClipEvent", "while",
"else", "in", "or", "with", "eq", "le", "return"));
cliOptions.clear();
cliOptions.add(new CliOption("packageName", "flash package name (convention: package.name), default: io.swagger"));
cliOptions.add(new CliOption("packageVersion", "flash package version, default: 1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "flash package name (convention:" +
" package.name), default: io.swagger"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "flash package version, " +
"default: 1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code. e.g. src/main/flex"));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated " +
"code. e.g. src/main/flex"));
}
@ -95,8 +99,8 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
}
if (additionalProperties.containsKey("packageName")) {
setPackageName((String) additionalProperties.get("packageName"));
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
apiPackage = packageName + ".client.api";
modelPackage = packageName + ".client.model";
}
@ -104,20 +108,21 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
setPackageName("io.swagger");
}
if (additionalProperties.containsKey("packageVersion")) {
setPackageVersion((String) additionalProperties.get("packageVersion"));
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
}
else {
setPackageVersion("1.0.0");
}
additionalProperties.put("packageName", packageName);
additionalProperties.put("packageVersion", packageVersion);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
//modelPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "model";
//apiPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "api";
final String invokerFolder = (sourceFolder + File.separator + invokerPackage + File.separator + "swagger" + File.separator).replace(".", File.separator).replace('.', File.separatorChar);
final String invokerFolder = (sourceFolder + File.separator + invokerPackage + File.separator
+ "swagger" + File.separator).replace(".", File.separator).replace('.', File.separatorChar);
supportingFiles.add(new SupportingFile("ApiInvoker.as", invokerFolder + "common", "ApiInvoker.as"));
supportingFiles.add(new SupportingFile("ApiUrlHelper.as", invokerFolder + "common", "ApiUrlHelper.as"));
@ -131,13 +136,20 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("Response.as", invokerFolder + "event", "Response.as"));
supportingFiles.add(new SupportingFile("build.properties", sourceFolder, "build.properties"));
supportingFiles.add(new SupportingFile("build.xml", sourceFolder, "build.xml"));
supportingFiles.add(new SupportingFile("AirExecutorApp-app.xml", sourceFolder + File.separatorChar + "bin", "AirExecutorApp-app.xml"));
supportingFiles.add(new SupportingFile("ASAXB-0.1.1.swc", sourceFolder + File.separatorChar + "lib", "ASAXB-0.1.1.swc"));
supportingFiles.add(new SupportingFile("as3corelib.swc", sourceFolder + File.separatorChar + "lib", "as3corelib.swc"));
supportingFiles.add(new SupportingFile("flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("AirExecutorApp-app.xml", sourceFolder + File.separatorChar
+ "bin", "AirExecutorApp-app.xml"));
supportingFiles.add(new SupportingFile("ASAXB-0.1.1.swc", sourceFolder + File.separatorChar
+ "lib", "ASAXB-0.1.1.swc"));
supportingFiles.add(new SupportingFile("as3corelib.swc", sourceFolder + File.separatorChar
+ "lib", "as3corelib.swc"));
supportingFiles.add(new SupportingFile("flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc", sourceFolder
+ File.separator + "lib" + File.separator + "ext", "flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder
+ File.separator + "lib" + File.separator + "ext", "flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder
+ File.separator + "lib" + File.separator + "ext", "flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc"));
supportingFiles.add(new SupportingFile("flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc", sourceFolder
+ File.separator + "lib" + File.separator + "ext", "flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc"));
}
private static String dropDots(String str) {
@ -163,11 +175,13 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String apiFileFolder() {
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar
+ apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
}
public String modelFileFolder() {
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar
+ modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
}
@Override

View File

@ -151,7 +151,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
}
if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) {
this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString()));
this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString()));
}
if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) {

View File

@ -19,6 +19,11 @@ import java.util.HashSet;
import org.apache.commons.lang3.StringUtils;
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String VARIABLE_NAMING_CONVENTION = "variableNamingConvention";
public static final String PACKAGE_PATH = "packagePath";
public static final String SRC_BASE_PATH = "srcBasePath";
public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
protected String invokerPackage = "Swagger\\Client";
protected String composerVendorName = "swagger";
protected String composerProjectName = "swagger-client";
@ -86,12 +91,12 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("object", "object");
typeMapping.put("DateTime", "\\DateTime");
cliOptions.add(new CliOption("variableNamingConvention", "naming convention of variable name, e.g. camelCase. Default: snake_case"));
cliOptions.add(new CliOption(VARIABLE_NAMING_CONVENTION, "naming convention of variable name, e.g. camelCase. Default: snake_case"));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets"));
cliOptions.add(new CliOption("packagePath", "The main package name for classes. e.g. GeneratedPetstore"));
cliOptions.add(new CliOption("srcBasePath", "The directory under packagePath to serve as source root."));
cliOptions.add(new CliOption("composerVendorName", "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets"));
cliOptions.add(new CliOption("composerProjectName", "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client"));
cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets"));
cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client"));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
}
@ -144,16 +149,16 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("packagePath")) {
this.setPackagePath((String) additionalProperties.get("packagePath"));
if (additionalProperties.containsKey(PACKAGE_PATH)) {
this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
} else {
additionalProperties.put("packagePath", packagePath);
additionalProperties.put(PACKAGE_PATH, packagePath);
}
if (additionalProperties.containsKey("srcBasePath")) {
this.setSrcBasePath((String) additionalProperties.get("srcBasePath"));
if (additionalProperties.containsKey(SRC_BASE_PATH)) {
this.setSrcBasePath((String) additionalProperties.get(SRC_BASE_PATH));
} else {
additionalProperties.put("srcBasePath", srcBasePath);
additionalProperties.put(SRC_BASE_PATH, srcBasePath);
}
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
@ -162,28 +167,24 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
} else {
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
}
if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
this.setApiPackage((String) additionalProperties.get(CodegenConstants.API_PACKAGE));
} else {
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
}
if (additionalProperties.containsKey("composerProjectName")) {
this.setComposerProjectName((String) additionalProperties.get("composerProjectName"));
if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
} else {
additionalProperties.put("composerProjectName", composerProjectName);
additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
}
if (additionalProperties.containsKey("composerVendorName")) {
this.setComposerVendorName((String) additionalProperties.get("composerVendorName"));
if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
} else {
additionalProperties.put("composerVendorName", composerVendorName);
additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
}
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
@ -191,6 +192,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
} else {
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
}
if (additionalProperties.containsKey(VARIABLE_NAMING_CONVENTION)) {
this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
}
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
@ -286,7 +291,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
this.variableNamingConvention = variableNamingConvention;
}
private void setComposerVendorName(String composerVendorName) {
public void setComposerVendorName(String composerVendorName) {
this.composerVendorName = composerVendorName;
}
@ -296,10 +301,6 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toVarName(String name) {
if (additionalProperties.containsKey("variableNamingConvention")) {
this.setParameterNamingConvention((String) additionalProperties.get("variableNamingConvention"));
}
// sanitize name
name = sanitizeName(name);

View File

@ -2,6 +2,7 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@ -62,30 +63,31 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
"return", "def", "for", "lambda", "try"));
cliOptions.clear();
cliOptions.add(new CliOption("packageName", "python package name (convention: snake_case), default: swagger_client"));
cliOptions.add(new CliOption("packageVersion", "python package version, default: 1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case)," +
" default: swagger_client"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "python package version, default: 1.0.0"));
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("packageName")) {
setPackageName((String) additionalProperties.get("packageName"));
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
}
else {
setPackageName("swagger_client");
}
if (additionalProperties.containsKey("packageVersion")) {
setPackageVersion((String) additionalProperties.get("packageVersion"));
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
}
else {
setPackageVersion("1.0.0");
}
additionalProperties.put("packageName", packageName);
additionalProperties.put("packageVersion", packageVersion);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
String swaggerFolder = packageName;

View File

@ -16,6 +16,9 @@ import java.util.HashSet;
import org.apache.commons.lang.StringUtils;
public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String GEM_NAME = "gemName";
public static final String MODULE_NAME = "moduleName";
public static final String GEM_VERSION = "gemVersion";
protected String gemName = null;
protected String moduleName = null;
protected String gemVersion = "1.0.0";
@ -68,20 +71,20 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
// remove modelPackage and apiPackage added by default
cliOptions.clear();
cliOptions.add(new CliOption("gemName", "gem name (convention: underscore_case), default: swagger_client"));
cliOptions.add(new CliOption("moduleName", "top module name (convention: CamelCase, usually corresponding to gem name), default: SwaggerClient"));
cliOptions.add(new CliOption("gemVersion", "gem version, default: 1.0.0"));
cliOptions.add(new CliOption(GEM_NAME, "gem name (convention: underscore_case), default: swagger_client"));
cliOptions.add(new CliOption(MODULE_NAME, "top module name (convention: CamelCase, usually corresponding to gem name), default: SwaggerClient"));
cliOptions.add(new CliOption(GEM_VERSION, "gem version, default: 1.0.0"));
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("gemName")) {
setGemName((String) additionalProperties.get("gemName"));
if (additionalProperties.containsKey(GEM_NAME)) {
setGemName((String) additionalProperties.get(GEM_NAME));
}
if (additionalProperties.containsKey("moduleName")) {
setModuleName((String) additionalProperties.get("moduleName"));
if (additionalProperties.containsKey(MODULE_NAME)) {
setModuleName((String) additionalProperties.get(MODULE_NAME));
}
if (gemName == null && moduleName == null) {
@ -93,14 +96,14 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
setModuleName(generateModuleName(gemName));
}
additionalProperties.put("gemName", gemName);
additionalProperties.put("moduleName", moduleName);
additionalProperties.put(GEM_NAME, gemName);
additionalProperties.put(MODULE_NAME, moduleName);
if (additionalProperties.containsKey("gemVersion")) {
setGemVersion((String) additionalProperties.get("gemVersion"));
if (additionalProperties.containsKey(GEM_VERSION)) {
setGemVersion((String) additionalProperties.get(GEM_VERSION));
} else {
// not set, pass the default value to template
additionalProperties.put("gemVersion", gemVersion);
additionalProperties.put(GEM_VERSION, gemVersion);
}
// use constant model/api package (folder path)

View File

@ -0,0 +1,71 @@
package io.swagger.codegen.android;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.AndroidClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class AndroidClientOptionsTest extends AbstractOptionsTest {
protected static final String ARTIFACT_ID_VALUE = "swagger-java-client-test";
protected static final String MODEL_PACKAGE_VALUE = "package";
protected static final String API_PACKAGE_VALUE = "apiPackage";
protected static final String INVOKER_PACKAGE_VALUE = "io.swagger.client.test";
protected static final String SORT_PARAMS_VALUE = "false";
protected static final String GROUP_ID_VALUE = "io.swagger.test";
protected static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
protected static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
protected static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true";
@Tested
private AndroidClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(API_PACKAGE_VALUE);
times = 1;
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
times = 1;
clientCodegen.setGroupId(GROUP_ID_VALUE);
times = 1;
clientCodegen.setArtifactId(ARTIFACT_ID_VALUE);
times = 1;
clientCodegen.setArtifactVersion(ARTIFACT_VERSION_VALUE);
times = 1;
clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
times = 1;
clientCodegen.setUseAndroidMavenGradlePlugin(Boolean.valueOf(ANDROID_MAVEN_GRADLE_PLUGIN_VALUE));
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
.put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
.put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.put(AndroidClientCodegen.USE_ANDROID_MAVEN_GRADLE_PLUGIN, ANDROID_MAVEN_GRADLE_PLUGIN_VALUE)
.build();
}
}

View File

@ -0,0 +1,43 @@
package io.swagger.codegen.csharp;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.CSharpClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class CSharpClientOptionsTest extends AbstractOptionsTest {
protected static final String PACKAGE_NAME_VALUE = "swagger_client_csharp";
protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
@Tested
private CSharpClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.build();
}
}

View File

@ -0,0 +1,47 @@
package io.swagger.codegen.csharpdotnettwo;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.CsharpDotNet2ClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class CsharpDotNet2ClientOptionsTest extends AbstractOptionsTest {
protected static final String PACKAGE_NAME_VALUE = "swagger_client_csharp_dotnet";
protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
protected static final String CLIENT_PACKAGE_VALUE = "IO.Swagger.Client.Test";
@Tested
private CsharpDotNet2ClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
times = 1;
clientCodegen.setClientPackage(CLIENT_PACKAGE_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CsharpDotNet2ClientCodegen.CLIENT_PACKAGE, CLIENT_PACKAGE_VALUE)
.build();
}
}

View File

@ -0,0 +1,68 @@
package io.swagger.codegen.dart;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.DartClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class DartClientOptionsTest extends AbstractOptionsTest {
protected static final String MODEL_PACKAGE_VALUE = "packagedart";
protected static final String API_PACKAGE_VALUE = "apiPackageDart";
protected static final String SORT_PARAMS_VALUE = "false";
protected static final String BROWSER_CLIENT_VALUE = "true";
protected static final String PUB_NAME_VALUE = "swagger";
protected static final String PUB_VERSION_VALUE = "1.0.0-SNAPSHOT";
protected static final String PUB_DESCRIPTION_VALUE = "Swagger API client dart";
protected static final String SOURCE_FOLDER_VALUE = "src";
@Tested
private DartClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(API_PACKAGE_VALUE);
times = 1;
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setBrowserClient(Boolean.valueOf(BROWSER_CLIENT_VALUE));
times = 1;
clientCodegen.setPubName(PUB_NAME_VALUE);
times = 1;
clientCodegen.setPubVersion(PUB_VERSION_VALUE);
times = 1;
clientCodegen.setPubDescription(PUB_DESCRIPTION_VALUE);
times = 1;
clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(DartClientCodegen.BROWSER_CLIENT, BROWSER_CLIENT_VALUE)
.put(DartClientCodegen.PUB_NAME, PUB_NAME_VALUE)
.put(DartClientCodegen.PUB_VERSION, PUB_VERSION_VALUE)
.put(DartClientCodegen.PUB_DESCRIPTION, PUB_DESCRIPTION_VALUE)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.build();
}
}

View File

@ -0,0 +1,51 @@
package io.swagger.codegen.flash;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.FlashClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class FlashClienOptionsTest extends AbstractOptionsTest {
protected static final String PACKAGE_NAME_VALUE = "io.swagger.flash";
protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
protected static final String INVOKER_PACKAGE_VALUE = "io.swagger.flash";
protected static final String SOURCE_FOLDER_VALUE = "src/main/flex/test";
@Tested
private FlashClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
times = 1;
clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
times = 1;
clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.build();
}
}

View File

@ -0,0 +1,48 @@
package io.swagger.codegen.nodejs;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.JavaClientCodegen;
import io.swagger.codegen.languages.NodeJSServerCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class NodeJSServerOptionsTest extends AbstractOptionsTest {
private static final String MODEL_PACKAGE_VALUE = "package";
private static final String API_PACKAGE_VALUE = "apiPackage";
private static final String SORT_PARAMS_VALUE = "false";
@Tested
private NodeJSServerCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(API_PACKAGE_VALUE);
times = 1;
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.build();
}
}

View File

@ -0,0 +1,75 @@
package io.swagger.codegen.php;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.PhpClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class PhpClientOptionsTest extends AbstractOptionsTest {
protected static final String MODEL_PACKAGE_VALUE = "package";
protected static final String API_PACKAGE_VALUE = "apiPackage";
protected static final String SORT_PARAMS_VALUE = "false";
protected static final String VARIABLE_NAMING_CONVENTION_VALUE = "snake_case";
protected static final String INVOKER_PACKAGE_VALUE = "Swagger\\Client\\Php";
protected static final String PACKAGE_PATH_VALUE = "SwaggerClient-php";
protected static final String SRC_BASE_PATH_VALUE = "libPhp";
protected static final String COMPOSER_VENDOR_NAME_VALUE = "swaggerPhp";
protected static final String COMPOSER_PROJECT_NAME_VALUE = "swagger-client-php";
protected static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
@Tested
private PhpClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(API_PACKAGE_VALUE);
times = 1;
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setParameterNamingConvention(VARIABLE_NAMING_CONVENTION_VALUE);
times = 1;
clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
times = 1;
clientCodegen.setPackagePath(PACKAGE_PATH_VALUE);
times = 1;
clientCodegen.setSrcBasePath(SRC_BASE_PATH_VALUE);
times = 1;
clientCodegen.setComposerVendorName(COMPOSER_VENDOR_NAME_VALUE);
times = 1;
clientCodegen.setComposerProjectName(COMPOSER_PROJECT_NAME_VALUE);
times = 1;
clientCodegen.setArtifactVersion(ARTIFACT_VERSION_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(PhpClientCodegen.VARIABLE_NAMING_CONVENTION, VARIABLE_NAMING_CONVENTION_VALUE)
.put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
.put(PhpClientCodegen.PACKAGE_PATH, PACKAGE_PATH_VALUE)
.put(PhpClientCodegen.SRC_BASE_PATH, SRC_BASE_PATH_VALUE)
.put(PhpClientCodegen.COMPOSER_VENDOR_NAME, COMPOSER_VENDOR_NAME_VALUE)
.put(PhpClientCodegen.COMPOSER_PROJECT_NAME, COMPOSER_PROJECT_NAME_VALUE)
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
.build();
}
}

View File

@ -0,0 +1,43 @@
package io.swagger.codegen.python;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.PythonClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class PythonClientOptionsTest extends AbstractOptionsTest {
protected static final String PACKAGE_NAME_VALUE = "swagger_client_python";
protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
@Tested
private PythonClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.build();
}
}

View File

@ -0,0 +1,46 @@
package io.swagger.codegen.ruby;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.languages.RubyClientCodegen;
import com.google.common.collect.ImmutableMap;
import mockit.Expectations;
import mockit.Tested;
import java.util.Map;
public class RubyClientOptionsTest extends AbstractOptionsTest {
private static final String GEM_NAME_VALUE = "swagger_client_ruby";
private static final String MODULE_NAME_VALUE = "SwaggerClientRuby";
private static final String GEM_VERSION_VALUE = "1.0.0-SNAPSHOT";
@Tested
private RubyClientCodegen clientCodegen;
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setGemName(GEM_NAME_VALUE);
times = 1;
clientCodegen.setModuleName(MODULE_NAME_VALUE);
times = 1;
clientCodegen.setGemVersion(GEM_VERSION_VALUE);
times = 1;
}};
}
@Override
protected Map<String, String> getAvaliableOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(RubyClientCodegen.GEM_NAME, GEM_NAME_VALUE)
.put(RubyClientCodegen.MODULE_NAME, MODULE_NAME_VALUE)
.put(RubyClientCodegen.GEM_VERSION, GEM_VERSION_VALUE)
.build();
}
}