mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
adding configurable options to the gemspec file
This commit is contained in:
parent
ccea106148
commit
3465a746d3
@ -19,10 +19,24 @@ 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";
|
||||
public static final String GEM_LICENSE = "gemLicense";
|
||||
public static final String GEM_HOMEPAGE = "gemHomepage";
|
||||
public static final String GEM_SUMMARY = "gemSummary";
|
||||
public static final String GEM_DESCRIPTION = "gemDescription";
|
||||
public static final String GEM_AUTHOR = "gemAuthor";
|
||||
public static final String GEM_AUTHOR_EMAIL = "gemAuthorEmail";
|
||||
|
||||
protected String gemName;
|
||||
protected String moduleName;
|
||||
protected String gemVersion = "1.0.0";
|
||||
protected String libFolder = "lib";
|
||||
protected String gemLicense = "Apache-2.0";
|
||||
protected String gemHomepage = "http://swagger.io";
|
||||
protected String gemSummary = "A ruby wrapper for the swagger APIs";
|
||||
protected String gemDescription = "This gem maps to a swagger API";
|
||||
protected String gemAuthor = "";
|
||||
protected String gemAuthorEmail = "";
|
||||
|
||||
|
||||
public RubyClientCodegen() {
|
||||
super();
|
||||
@ -87,6 +101,23 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
cliOptions.add(new CliOption(MODULE_NAME, "top module name (convention: CamelCase, usually corresponding" +
|
||||
" to gem name).").defaultValue("SwaggerClient"));
|
||||
cliOptions.add(new CliOption(GEM_VERSION, "gem version.").defaultValue("1.0.0"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_LICENSE, "gem license. ").
|
||||
defaultValue("Apache-2.0"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_HOMEPAGE, "gem homepage. ").
|
||||
defaultValue("http://swagger.io"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_SUMMARY, "gem summary. ").
|
||||
defaultValue("A ruby wrapper for the swagger APIs"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_DESCRIPTION, "gem description. ").
|
||||
defaultValue("This gem maps to a swagger API"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_AUTHOR, "gem author (only one is supported)."));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_AUTHOR_EMAIL, "gem author email (only one is supported)."));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,11 +145,36 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (additionalProperties.containsKey(GEM_VERSION)) {
|
||||
setGemVersion((String) additionalProperties.get(GEM_VERSION));
|
||||
} else {
|
||||
}else {
|
||||
// not set, pass the default value to template
|
||||
additionalProperties.put(GEM_VERSION, gemVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_LICENSE)) {
|
||||
setGemLicense((String) additionalProperties.get(GEM_LICENSE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_HOMEPAGE)) {
|
||||
setGemHomepage((String) additionalProperties.get(GEM_HOMEPAGE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_SUMMARY)) {
|
||||
setGemSummary((String) additionalProperties.get(GEM_SUMMARY));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_DESCRIPTION)) {
|
||||
setGemDescription((String) additionalProperties.get(GEM_DESCRIPTION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_AUTHOR)) {
|
||||
setGemAuthor((String) additionalProperties.get(GEM_AUTHOR));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_AUTHOR_EMAIL)) {
|
||||
setGemAuthorEmail((String) additionalProperties.get(GEM_AUTHOR_EMAIL));
|
||||
}
|
||||
|
||||
|
||||
// use constant model/api package (folder path)
|
||||
setModelPackage("models");
|
||||
setApiPackage("api");
|
||||
@ -133,6 +189,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
String modelFolder = gemFolder + File.separator + modelPackage.replace("/", File.separator);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
@ -354,4 +411,28 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void setGemVersion(String gemVersion) {
|
||||
this.gemVersion = gemVersion;
|
||||
}
|
||||
|
||||
public void setGemDescription(String gemDescription) {
|
||||
this.gemDescription = gemDescription;
|
||||
}
|
||||
|
||||
public void setGemSummary(String gemSummary) {
|
||||
this.gemSummary = gemSummary;
|
||||
}
|
||||
|
||||
public void setGemLicense(String gemLicense) {
|
||||
this.gemLicense = gemLicense;
|
||||
}
|
||||
|
||||
public void setGemHomepage(String gemHomepage) {
|
||||
this.gemHomepage = gemHomepage;
|
||||
}
|
||||
|
||||
public void setGemAuthor(String gemAuthor) {
|
||||
this.gemAuthor = gemAuthor;
|
||||
}
|
||||
|
||||
public void setGemAuthorEmail(String gemAuthorEmail) {
|
||||
this.gemAuthorEmail = gemAuthorEmail;
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,13 @@ Gem::Specification.new do |s|
|
||||
s.name = "{{gemName}}"
|
||||
s.version = {{moduleName}}::VERSION
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.authors = ["Zeke Sikelianos", "Tony Tam"]
|
||||
s.email = ["zeke@wordnik.com", "fehguy@gmail.com"]
|
||||
s.homepage = "http://swagger.io"
|
||||
s.summary = %q{A ruby wrapper for the swagger APIs}
|
||||
s.description = %q{This gem maps to a swagger API}
|
||||
s.license = "Apache-2.0"
|
||||
s.authors = ["{{gemAuthor}}"]
|
||||
s.email = ["{{gemAuthorEmail}}"]
|
||||
s.homepage = "{{gemHomepage}}"
|
||||
s.summary = "{{gemSummary}}"
|
||||
s.description = "{{gemDescription}}"
|
||||
s.license = "{{gemLicense}}"
|
||||
|
||||
|
||||
s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1'
|
||||
s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6'
|
||||
|
@ -13,6 +13,12 @@ public class RubyClientOptionsProvider implements OptionsProvider {
|
||||
public static final String GEM_VERSION_VALUE = "1.0.0-SNAPSHOT";
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
public static final String GEM_LICENSE_VALUE = "MIT";
|
||||
public static final String GEM_HOMEPAGE_VALUE = "homepage";
|
||||
public static final String GEM_SUMMARY_VALUE = "summary";
|
||||
public static final String GEM_DESCRIPTION_VALUE = "description";
|
||||
public static final String GEM_AUTHOR_VALUE = "foo";
|
||||
public static final String GEM_AUTHOR_EMAIL_VALUE = "foo";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
@ -25,6 +31,12 @@ public class RubyClientOptionsProvider implements OptionsProvider {
|
||||
return builder.put(RubyClientCodegen.GEM_NAME, GEM_NAME_VALUE)
|
||||
.put(RubyClientCodegen.MODULE_NAME, MODULE_NAME_VALUE)
|
||||
.put(RubyClientCodegen.GEM_VERSION, GEM_VERSION_VALUE)
|
||||
.put(RubyClientCodegen.GEM_LICENSE, GEM_LICENSE_VALUE)
|
||||
.put(RubyClientCodegen.GEM_DESCRIPTION, GEM_DESCRIPTION_VALUE)
|
||||
.put(RubyClientCodegen.GEM_HOMEPAGE, GEM_HOMEPAGE_VALUE)
|
||||
.put(RubyClientCodegen.GEM_SUMMARY, GEM_SUMMARY_VALUE)
|
||||
.put(RubyClientCodegen.GEM_AUTHOR, GEM_AUTHOR_VALUE)
|
||||
.put(RubyClientCodegen.GEM_AUTHOR_EMAIL, GEM_AUTHOR_EMAIL_VALUE)
|
||||
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||
.build();
|
||||
|
@ -31,6 +31,19 @@ public class RubyClientOptionsTest extends AbstractOptionsTest {
|
||||
times = 1;
|
||||
clientCodegen.setGemVersion(RubyClientOptionsProvider.GEM_VERSION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemLicense(RubyClientOptionsProvider.GEM_LICENSE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemHomepage(RubyClientOptionsProvider.GEM_HOMEPAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemDescription(RubyClientOptionsProvider.GEM_DESCRIPTION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemSummary(RubyClientOptionsProvider.GEM_SUMMARY_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemAuthor(RubyClientOptionsProvider.GEM_AUTHOR_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemAuthorEmail(RubyClientOptionsProvider.GEM_AUTHOR_EMAIL_VALUE);
|
||||
times = 1;
|
||||
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user