Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Ruby module/gem to codegen constant #2621

Merged
merged 2 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public class CodegenConstants {
public static final String PERL_MODULE_NAME = "perlModuleName";
public static final String PERL_MODULE_NAME_DESC = "root module name for generated perl code";

public static final String MODULE_NAME = "moduleName";
public static final String MODULE_NAME_DESC = "top module name (convention: CamelCase, usually corresponding to gem name).";

public static final String GEM_NAME = "gemName";
public static final String GEM_NAME_DESC = "gem name (convention: underscore_case).";

public static final String PYTHON_PACKAGE_NAME = "pythonPackageName";
public static final String PYTHON_PACKAGE_NAME_DESC = "package name for generated python code";

Expand Down Expand Up @@ -277,13 +283,13 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
public static final String ENABLE_POST_PROCESS_FILE_DESC = "Enable post-processing file using environment variables.";

public static final String OPEN_API_SPEC_NAME = "openAPISpecName";

public static final String GENERATE_ALIAS_AS_MODEL = "generateAliasAsModel";
public static final String GENERATE_ALIAS_AS_MODEL_DESC = "Generate alias to map, array as models";

public static final String USE_COMPARE_NET_OBJECTS = "useCompareNetObjects";
public static final String USE_COMPARE_NET_OBJECTS_DESC = "Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.";

public static final String SNAPSHOT_VERSION = "snapshotVersion";
public static final String SNAPSHOT_VERSION_DESC = "Uses a SNAPSHOT version.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
public class RubyClientCodegen extends AbstractRubyCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
private static final String NUMERIC_ENUM_PREFIX = "N";
public static final String GEM_NAME = "gemName";
public static final String MODULE_NAME = "moduleName";
public static final String GEM_VERSION = "gemVersion";
public static final String GEM_LICENSE = "gemLicense";
public static final String GEM_REQUIRED_RUBY_VERSION = "gemRequiredRubyVersion";
Expand Down Expand Up @@ -113,10 +111,12 @@ public RubyClientCodegen() {
}
}

cliOptions.add(new CliOption(GEM_NAME, "gem name (convention: underscore_case).").
cliOptions.add(new CliOption(CodegenConstants.GEM_NAME, CodegenConstants.GEM_NAME_DESC).
defaultValue("openapi_client"));
cliOptions.add(new CliOption(MODULE_NAME, "top module name (convention: CamelCase, usually corresponding" +
" to gem name).").defaultValue("OpenAPIClient"));

cliOptions.add(new CliOption(CodegenConstants.MODULE_NAME, CodegenConstants.MODULE_NAME_DESC).
defaultValue("OpenAPIClient"));

cliOptions.add(new CliOption(GEM_VERSION, "gem version.").defaultValue("1.0.0"));

cliOptions.add(new CliOption(GEM_LICENSE, "gem license. ").
Expand Down Expand Up @@ -147,11 +147,11 @@ public RubyClientCodegen() {
public void processOpts() {
super.processOpts();

if (additionalProperties.containsKey(GEM_NAME)) {
setGemName((String) additionalProperties.get(GEM_NAME));
if (additionalProperties.containsKey(CodegenConstants.GEM_NAME)) {
setGemName((String) additionalProperties.get(CodegenConstants.GEM_NAME));
}
if (additionalProperties.containsKey(MODULE_NAME)) {
setModuleName((String) additionalProperties.get(MODULE_NAME));
if (additionalProperties.containsKey(CodegenConstants.MODULE_NAME)) {
setModuleName((String) additionalProperties.get(CodegenConstants.MODULE_NAME));
}

if (gemName == null && moduleName == null) {
Expand All @@ -163,8 +163,8 @@ public void processOpts() {
setModuleName(generateModuleName(gemName));
}

additionalProperties.put(GEM_NAME, gemName);
additionalProperties.put(MODULE_NAME, moduleName);
additionalProperties.put(CodegenConstants.GEM_NAME, gemName);
additionalProperties.put(CodegenConstants.MODULE_NAME, moduleName);

if (additionalProperties.containsKey(GEM_VERSION)) {
setGemVersion((String) additionalProperties.get(GEM_VERSION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public String getLanguage() {
@Override
public Map<String, String> createOptions() {
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)
return builder.put(CodegenConstants.GEM_NAME, GEM_NAME_VALUE)
.put(CodegenConstants.MODULE_NAME, MODULE_NAME_VALUE)
.put(RubyClientCodegen.GEM_VERSION, GEM_VERSION_VALUE)
.put(RubyClientCodegen.GEM_LICENSE, GEM_LICENSE_VALUE)
.put(RubyClientCodegen.GEM_REQUIRED_RUBY_VERSION, GEM_REQUIRED_RUBY_VERSION_VALUE)
Expand Down