forked from loafle/openapi-generator-original
[ruby] Add gemspec required_ruby_version setting. (#3718)
* [ruby] Add gemspec required_ruby_version setting. * [ruby] Add gemspec required_ruby_version setting. * Add gemRequiredRubyVersion option to Ruby client code generator.
This commit is contained in:
parent
23283cb0c0
commit
92eb722ced
@ -30,6 +30,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
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";
|
||||
public static final String GEM_HOMEPAGE = "gemHomepage";
|
||||
public static final String GEM_SUMMARY = "gemSummary";
|
||||
public static final String GEM_DESCRIPTION = "gemDescription";
|
||||
@ -42,6 +43,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String specFolder = "spec";
|
||||
protected String libFolder = "lib";
|
||||
protected String gemLicense = "Apache-2.0";
|
||||
protected String gemRequiredRubyVersion = ">= 1.9";
|
||||
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";
|
||||
@ -143,6 +145,9 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
cliOptions.add(new CliOption(GEM_LICENSE, "gem license. ").
|
||||
defaultValue("Apache-2.0"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_REQUIRED_RUBY_VERSION, "gem required Ruby version. ").
|
||||
defaultValue(">= 1.9"));
|
||||
|
||||
cliOptions.add(new CliOption(GEM_HOMEPAGE, "gem homepage. ").
|
||||
defaultValue("http://swagger.io"));
|
||||
|
||||
@ -203,6 +208,10 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
setGemLicense((String) additionalProperties.get(GEM_LICENSE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_REQUIRED_RUBY_VERSION)) {
|
||||
setGemRequiredRubyVersion((String) additionalProperties.get(GEM_REQUIRED_RUBY_VERSION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GEM_HOMEPAGE)) {
|
||||
setGemHomepage((String) additionalProperties.get(GEM_HOMEPAGE));
|
||||
}
|
||||
@ -708,6 +717,10 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
this.gemLicense = gemLicense;
|
||||
}
|
||||
|
||||
public void setGemRequiredRubyVersion(String gemRequiredRubyVersion) {
|
||||
this.gemRequiredRubyVersion = gemRequiredRubyVersion;
|
||||
}
|
||||
|
||||
public void setGemHomepage(String gemHomepage) {
|
||||
this.gemHomepage = gemHomepage;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
||||
s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
|
||||
s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
|
||||
s.license = "{{gemLicense}}{{^gemLicense}}{{{licenseInfo}}}{{^licenseInfo}}Apache 2.0{{/licenseInfo}}{{/gemLicense}}"
|
||||
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
|
||||
|
||||
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
||||
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
||||
|
@ -14,6 +14,7 @@ public class RubyClientOptionsProvider implements OptionsProvider {
|
||||
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_REQUIRED_RUBY_VERSION_VALUE = ">= 1.9";
|
||||
public static final String GEM_HOMEPAGE_VALUE = "homepage";
|
||||
public static final String GEM_SUMMARY_VALUE = "summary";
|
||||
public static final String GEM_DESCRIPTION_VALUE = "description";
|
||||
@ -32,6 +33,7 @@ public class RubyClientOptionsProvider implements OptionsProvider {
|
||||
.put(RubyClientCodegen.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)
|
||||
.put(RubyClientCodegen.GEM_DESCRIPTION, GEM_DESCRIPTION_VALUE)
|
||||
.put(RubyClientCodegen.GEM_HOMEPAGE, GEM_HOMEPAGE_VALUE)
|
||||
.put(RubyClientCodegen.GEM_SUMMARY, GEM_SUMMARY_VALUE)
|
||||
|
@ -34,6 +34,8 @@ public class RubyClientOptionsTest extends AbstractOptionsTest {
|
||||
times = 1;
|
||||
clientCodegen.setGemLicense(RubyClientOptionsProvider.GEM_LICENSE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemRequiredRubyVersion(RubyClientOptionsProvider.GEM_REQUIRED_RUBY_VERSION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemHomepage(RubyClientOptionsProvider.GEM_HOMEPAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGemDescription(RubyClientOptionsProvider.GEM_DESCRIPTION_VALUE);
|
||||
|
@ -8,6 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build date: 2016-09-04T00:22:35.922+10:00
|
||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||
|
||||
## Installation
|
||||
|
@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
||||
s.summary = "Swagger Petstore Ruby Gem"
|
||||
s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\"
|
||||
s.license = "Apache 2.0"
|
||||
s.required_ruby_version = ">= 1.9"
|
||||
|
||||
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
||||
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
||||
|
Loading…
x
Reference in New Issue
Block a user