forked from loafle/openapi-generator-original
processOptions tests have been added for Objc, perl, spring-mvc, swift, scala, async-scala, qt5cpp, html, dynamic-html, swagger, swagger-yaml, tizen, typescript-angular, typescript-node, akka-scala, inflector, scalatra, silex and sinatra
This commit is contained in:
@@ -42,4 +42,5 @@ public class CodegenConstants {
|
||||
|
||||
public static final String PACKAGE_NAME = "packageName";
|
||||
public static final String PACKAGE_VERSION = "packageVersion";
|
||||
public static final String POD_VERSION = "podVersion";
|
||||
}
|
||||
|
||||
@@ -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.CodegenProperty;
|
||||
import io.swagger.codegen.CodegenType;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
@@ -19,6 +20,12 @@ import java.util.Set;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public static final String CLASS_PREFIX = "classPrefix";
|
||||
public static final String POD_NAME = "podName";
|
||||
public static final String AUTHOR_NAME = "authorName";
|
||||
public static final String AUTHOR_EMAIL = "authorEmail";
|
||||
public static final String GIT_REPO_URL = "gitRepoURL";
|
||||
public static final String LICENSE = "license";
|
||||
protected Set<String> foundationClasses = new HashSet<String>();
|
||||
protected String podName = "SwaggerClient";
|
||||
protected String podVersion = "1.0.0";
|
||||
@@ -113,13 +120,13 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
instantiationTypes.put("map", "NSMutableDictionary");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption("classPrefix", "prefix for generated classes (convention: Abbreviation of pod name e.g. `HN` for `HackerNews`), default: `SWG`"));
|
||||
cliOptions.add(new CliOption("podName", "cocoapods package name (convention: CameCase), default: `SwaggerClient`"));
|
||||
cliOptions.add(new CliOption("podVersion", "cocoapods package version, default: `1.0.0`"));
|
||||
cliOptions.add(new CliOption("authorName", "Name to use in the podspec file, default: `Swagger`"));
|
||||
cliOptions.add(new CliOption("authorEmail", "Email to use in the podspec file, default: `apiteam@swagger.io`"));
|
||||
cliOptions.add(new CliOption("gitRepoURL", "URL for the git repo where this podspec should point to, default: `https://github.com/swagger-api/swagger-codegen`"));
|
||||
cliOptions.add(new CliOption("license", "License to use in the podspec file, default: `MIT`"));
|
||||
cliOptions.add(new CliOption(CLASS_PREFIX, "prefix for generated classes (convention: Abbreviation of pod name e.g. `HN` for `HackerNews`), default: `SWG`"));
|
||||
cliOptions.add(new CliOption(POD_NAME, "cocoapods package name (convention: CameCase), default: `SwaggerClient`"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.POD_VERSION, "cocoapods package version, default: `1.0.0`"));
|
||||
cliOptions.add(new CliOption(AUTHOR_NAME, "Name to use in the podspec file, default: `Swagger`"));
|
||||
cliOptions.add(new CliOption(AUTHOR_EMAIL, "Email to use in the podspec file, default: `apiteam@swagger.io`"));
|
||||
cliOptions.add(new CliOption(GIT_REPO_URL, "URL for the git repo where this podspec should point to, default: `https://github.com/swagger-api/swagger-codegen`"));
|
||||
cliOptions.add(new CliOption(LICENSE, "License to use in the podspec file, default: `MIT`"));
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
@@ -138,41 +145,41 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey("podName")) {
|
||||
setPodName((String) additionalProperties.get("podName"));
|
||||
if (additionalProperties.containsKey(POD_NAME)) {
|
||||
setPodName((String) additionalProperties.get(POD_NAME));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("podVersion")) {
|
||||
setPodVersion((String) additionalProperties.get("podVersion"));
|
||||
if (additionalProperties.containsKey(CodegenConstants.POD_VERSION)) {
|
||||
setPodVersion((String) additionalProperties.get(CodegenConstants.POD_VERSION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("classPrefix")) {
|
||||
setClassPrefix((String) additionalProperties.get("classPrefix"));
|
||||
if (additionalProperties.containsKey(CLASS_PREFIX)) {
|
||||
setClassPrefix((String) additionalProperties.get(CLASS_PREFIX));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("authorName")) {
|
||||
setAuthorName((String) additionalProperties.get("authorName"));
|
||||
if (additionalProperties.containsKey(AUTHOR_NAME)) {
|
||||
setAuthorName((String) additionalProperties.get(AUTHOR_NAME));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("authorEmail")) {
|
||||
setAuthorEmail((String) additionalProperties.get("authorEmail"));
|
||||
if (additionalProperties.containsKey(AUTHOR_EMAIL)) {
|
||||
setAuthorEmail((String) additionalProperties.get(AUTHOR_EMAIL));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("gitRepoURL")) {
|
||||
setGitRepoURL((String) additionalProperties.get("gitRepoURL"));
|
||||
if (additionalProperties.containsKey(GIT_REPO_URL)) {
|
||||
setGitRepoURL((String) additionalProperties.get(GIT_REPO_URL));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("license")) {
|
||||
setLicense((String) additionalProperties.get("license"));
|
||||
if (additionalProperties.containsKey(LICENSE)) {
|
||||
setLicense((String) additionalProperties.get(LICENSE));
|
||||
}
|
||||
|
||||
additionalProperties.put("podName", podName);
|
||||
additionalProperties.put("podVersion", podVersion);
|
||||
additionalProperties.put("classPrefix", classPrefix);
|
||||
additionalProperties.put("authorName", authorName);
|
||||
additionalProperties.put("authorEmail", authorEmail);
|
||||
additionalProperties.put("gitRepoURL", gitRepoURL);
|
||||
additionalProperties.put("license", license);
|
||||
additionalProperties.put(POD_NAME, podName);
|
||||
additionalProperties.put(CodegenConstants.POD_VERSION, podVersion);
|
||||
additionalProperties.put(CLASS_PREFIX, classPrefix);
|
||||
additionalProperties.put(AUTHOR_NAME, authorName);
|
||||
additionalProperties.put(AUTHOR_EMAIL, authorEmail);
|
||||
additionalProperties.put(GIT_REPO_URL, gitRepoURL);
|
||||
additionalProperties.put(LICENSE, license);
|
||||
|
||||
String swaggerFolder = podName;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.HashSet;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public static final String MODULE_NAME = "moduleName";
|
||||
public static final String MODULE_VERSION = "moduleVersion";
|
||||
protected String moduleName = "SwaggerClient";
|
||||
protected String moduleVersion = "1.0.0";
|
||||
|
||||
@@ -68,8 +70,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("object", "object");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption("moduleName", "perl module name (convention: CamelCase), default: SwaggerClient"));
|
||||
cliOptions.add(new CliOption("moduleVersion", "perl module version, default: 1.0.0"));
|
||||
cliOptions.add(new CliOption(MODULE_NAME, "perl module name (convention: CamelCase), default: SwaggerClient"));
|
||||
cliOptions.add(new CliOption(MODULE_VERSION, "perl module version, default: 1.0.0"));
|
||||
}
|
||||
|
||||
|
||||
@@ -77,16 +79,16 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey("moduleVersion")) {
|
||||
moduleVersion = (String) additionalProperties.get("moduleVersion");
|
||||
if (additionalProperties.containsKey(MODULE_VERSION)) {
|
||||
setModuleVersion((String) additionalProperties.get(MODULE_VERSION));
|
||||
} else {
|
||||
additionalProperties.put("moduleVersion", moduleVersion);
|
||||
additionalProperties.put(MODULE_VERSION, moduleVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("moduleName")) {
|
||||
moduleName = (String) additionalProperties.get("moduleName");
|
||||
if (additionalProperties.containsKey(MODULE_NAME)) {
|
||||
setModuleName((String) additionalProperties.get(MODULE_NAME));
|
||||
} else {
|
||||
additionalProperties.put("moduleName", moduleName);
|
||||
additionalProperties.put(MODULE_NAME, moduleName);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "ApiClient.pm"));
|
||||
@@ -229,5 +231,11 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return underscore(operationId);
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public void setModuleVersion(String moduleVersion) {
|
||||
this.moduleVersion = moduleVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SpringMVCServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
||||
public static final String CONFIG_PACKAGE = "configPackage";
|
||||
protected String title = "Petstore Server";
|
||||
protected String configPackage = "";
|
||||
|
||||
@@ -36,7 +37,7 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
additionalProperties.put("title", title);
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
additionalProperties.put("configPackage", configPackage);
|
||||
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
@@ -49,8 +50,7 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
"Float")
|
||||
);
|
||||
|
||||
cliOptions.add(new CliOption("configPackage", "configuration package for generated code"));
|
||||
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
@@ -69,8 +69,8 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey("configPackage")) {
|
||||
this.setConfigPackage((String) additionalProperties.get("configPackage"));
|
||||
if (additionalProperties.containsKey(CONFIG_PACKAGE)) {
|
||||
this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE));
|
||||
}
|
||||
|
||||
supportingFiles.clear();
|
||||
|
||||
@@ -24,13 +24,26 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\{[a-zA-Z_]+\\}");
|
||||
public static final String PROJECT_NAME = "projectName";
|
||||
public static final String RESPONSE_AS = "responseAs";
|
||||
public static final String UNWRAP_REQUIRED = "unwrapRequired";
|
||||
public static final String POD_SOURCE = "podSource";
|
||||
public static final String POD_AUTHORS = "podAuthors";
|
||||
public static final String POD_SOCIAL_MEDIA_URL = "podSocialMediaURL";
|
||||
public static final String POD_DOCSET_URL = "podDocsetURL";
|
||||
public static final String POD_LICENSE = "podLicense";
|
||||
public static final String POD_HOMEPAGE = "podHomepage";
|
||||
public static final String POD_SUMMARY = "podSummary";
|
||||
public static final String POD_DESCRIPTION = "podDescription";
|
||||
public static final String POD_SCREENSHOTS = "podScreenshots";
|
||||
public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
|
||||
protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
|
||||
protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT };
|
||||
protected String projectName = "SwaggerClient";
|
||||
protected boolean unwrapRequired = false;
|
||||
protected String[] responseAs = new String[0];
|
||||
protected String sourceFolder = "Classes" + File.separator + "Swaggers";
|
||||
private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\{[a-zA-Z_]+\\}");
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
@@ -107,22 +120,22 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
cliOptions.add(new CliOption("projectName", "Project name in Xcode"));
|
||||
cliOptions.add(new CliOption("responseAs", "Optionally use libraries to manage response. Currently " +
|
||||
cliOptions.add(new CliOption(PROJECT_NAME, "Project name in Xcode"));
|
||||
cliOptions.add(new CliOption(RESPONSE_AS, "Optionally use libraries to manage response. Currently " +
|
||||
StringUtils.join(RESPONSE_LIBRARIES, ", ") + " are available."));
|
||||
cliOptions.add(new CliOption("unwrapRequired", "Treat 'required' properties in response as non-optional " +
|
||||
cliOptions.add(new CliOption(UNWRAP_REQUIRED, "Treat 'required' properties in response as non-optional " +
|
||||
"(which would crash the app if api returns null as opposed to required option specified in json schema"));
|
||||
cliOptions.add(new CliOption("podSource", "Source information used for Podspec"));
|
||||
cliOptions.add(new CliOption("podVersion", "Version used for Podspec"));
|
||||
cliOptions.add(new CliOption("podAuthors", "Authors used for Podspec"));
|
||||
cliOptions.add(new CliOption("podSocialMediaURL", "Social Media URL used for Podspec"));
|
||||
cliOptions.add(new CliOption("podDocsetURL", "Docset URL used for Podspec"));
|
||||
cliOptions.add(new CliOption("podLicense", "License used for Podspec"));
|
||||
cliOptions.add(new CliOption("podHomepage", "Homepage used for Podspec"));
|
||||
cliOptions.add(new CliOption("podSummary", "Summary used for Podspec"));
|
||||
cliOptions.add(new CliOption("podDescription", "Description used for Podspec"));
|
||||
cliOptions.add(new CliOption("podScreenshots", "Screenshots used for Podspec"));
|
||||
cliOptions.add(new CliOption("podDocumentationURL", "Documentation URL used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_SOURCE, "Source information used for Podspec"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.POD_VERSION, "Version used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_AUTHORS, "Authors used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_SOCIAL_MEDIA_URL, "Social Media URL used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_DOCSET_URL, "Docset URL used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_LICENSE, "License used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_HOMEPAGE, "Homepage used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_SUMMARY, "Summary used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_DESCRIPTION, "Description used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_SCREENSHOTS, "Screenshots used for Podspec"));
|
||||
cliOptions.add(new CliOption(POD_DOCUMENTATION_URL, "Documentation URL used for Podspec"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,29 +143,29 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
super.processOpts();
|
||||
|
||||
// Setup project name
|
||||
if (additionalProperties.containsKey("projectName")) {
|
||||
projectName = (String) additionalProperties.get("projectName");
|
||||
if (additionalProperties.containsKey(PROJECT_NAME)) {
|
||||
setProjectName((String) additionalProperties.get(PROJECT_NAME));
|
||||
} else {
|
||||
additionalProperties.put("projectName", projectName);
|
||||
additionalProperties.put(PROJECT_NAME, projectName);
|
||||
}
|
||||
sourceFolder = projectName + File.separator + sourceFolder;
|
||||
|
||||
// Setup unwrapRequired option, which makes all the properties with "required" non-optional
|
||||
if (additionalProperties.containsKey("unwrapRequired")) {
|
||||
unwrapRequired = Boolean.parseBoolean(String.valueOf(additionalProperties.get("unwrapRequired")));
|
||||
if (additionalProperties.containsKey(UNWRAP_REQUIRED)) {
|
||||
setUnwrapRequired(Boolean.parseBoolean(String.valueOf(additionalProperties.get(UNWRAP_REQUIRED))));
|
||||
}
|
||||
additionalProperties.put("unwrapRequired", unwrapRequired);
|
||||
additionalProperties.put(UNWRAP_REQUIRED, unwrapRequired);
|
||||
|
||||
// Setup unwrapRequired option, which makes all the properties with "required" non-optional
|
||||
if (additionalProperties.containsKey("responseAs")) {
|
||||
Object responseAsObject = additionalProperties.get("responseAs");
|
||||
if (additionalProperties.containsKey(RESPONSE_AS)) {
|
||||
Object responseAsObject = additionalProperties.get(RESPONSE_AS);
|
||||
if (responseAsObject instanceof String) {
|
||||
responseAs = ((String)responseAsObject).split(",");
|
||||
setResponseAs(((String)responseAsObject).split(","));
|
||||
} else {
|
||||
responseAs = (String[]) responseAsObject;
|
||||
setResponseAs((String[]) responseAsObject);
|
||||
}
|
||||
}
|
||||
additionalProperties.put("responseAs", responseAs);
|
||||
additionalProperties.put(RESPONSE_AS, responseAs);
|
||||
if (ArrayUtils.contains(responseAs, LIBRARY_PROMISE_KIT)) {
|
||||
additionalProperties.put("usePromiseKit", true);
|
||||
}
|
||||
@@ -308,4 +321,16 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setUnwrapRequired(boolean unwrapRequired) {
|
||||
this.unwrapRequired = unwrapRequired;
|
||||
}
|
||||
|
||||
public void setResponseAs(String[] responseAs) {
|
||||
this.responseAs = responseAs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user