Skip to content
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
1 change: 1 addition & 0 deletions docs/generators/ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|gemDescription|gem description. | |This gem maps to a REST API|
|gemHomepage|gem homepage. | |https://openapi-generator.tech|
|gemLicense|gem license. | |unlicense|
|gemMetadata|gem metadata.| |{}|
|gemName|gem name (convention: underscore_case).| |openapi_client|
|gemRequiredRubyVersion|gem required Ruby version. | |>= 2.4|
|gemSummary|gem summary. | |A ruby wrapper for the REST APIs|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
public static final String GEM_DESCRIPTION = "gemDescription";
public static final String GEM_AUTHOR = "gemAuthor";
public static final String GEM_AUTHOR_EMAIL = "gemAuthorEmail";
public static final String GEM_METADATA = "gemMetadata";
public static final String FARADAY = "faraday";
public static final String HTTPX = "httpx";
public static final String TYPHOEUS = "typhoeus";
Expand All @@ -66,6 +67,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
protected String gemSummary = "A Ruby SDK for the REST API";
protected String gemDescription = "This gem maps to a REST API";
protected String gemAuthor = "";
protected String gemMetadata = "{}";
protected String gemAuthorEmail = "";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
Expand Down Expand Up @@ -170,6 +172,9 @@ public RubyClientCodegen() {

cliOptions.add(new CliOption(GEM_AUTHOR_EMAIL, "gem author email (only one is supported)."));

cliOptions.add(new CliOption(GEM_METADATA, "gem metadata.").
defaultValue("{}"));

cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).
defaultValue(Boolean.TRUE.toString()));

Expand Down Expand Up @@ -246,6 +251,10 @@ public void processOpts() {
setGemAuthorEmail((String) additionalProperties.get(GEM_AUTHOR_EMAIL));
}

if (additionalProperties.containsKey(GEM_METADATA)) {
setGemMetadata((String) additionalProperties.get(GEM_METADATA));
}

if (additionalProperties.containsKey(USE_AUTOLOAD)) {
setUseAutoload(convertPropertyToBooleanAndWriteBack(USE_AUTOLOAD));
}
Expand Down Expand Up @@ -613,6 +622,10 @@ public void setGemAuthorEmail(String gemAuthorEmail) {
this.gemAuthorEmail = gemAuthorEmail;
}

public void setGemMetadata(String gemMetadata) {
this.gemMetadata = gemMetadata;
}

public void setUseAutoload(boolean useAutoload) {
this.useAutoload = useAutoload;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |s|
s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}"
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.7{{/gemRequiredRubyVersion}}"
s.metadata = {{{gemMetadata}}}{{^gemMetadata}}{}{{/gemMetadata}}

{{#isFaraday}}
s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class RubyClientOptionsProvider implements OptionsProvider {
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_METADATA_VALUE = "{}";
public static final String GEM_AUTHOR_EMAIL_VALUE = "foo";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
Expand All @@ -61,6 +62,7 @@ public Map<String, String> createOptions() {
.put(RubyClientCodegen.GEM_SUMMARY, GEM_SUMMARY_VALUE)
.put(RubyClientCodegen.GEM_AUTHOR, GEM_AUTHOR_VALUE)
.put(RubyClientCodegen.GEM_AUTHOR_EMAIL, GEM_AUTHOR_EMAIL_VALUE)
.put(RubyClientCodegen.GEM_METADATA, GEM_METADATA_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, SORT_MODEL_PROPERTIES_VALUE)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected void verifyOptions() {
verify(clientCodegen).setGemSummary(RubyClientOptionsProvider.GEM_SUMMARY_VALUE);
verify(clientCodegen).setGemAuthor(RubyClientOptionsProvider.GEM_AUTHOR_VALUE);
verify(clientCodegen).setGemAuthorEmail(RubyClientOptionsProvider.GEM_AUTHOR_EMAIL_VALUE);
verify(clientCodegen).setGemMetadata(RubyClientOptionsProvider.GEM_METADATA_VALUE);
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(RubyClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
verify(clientCodegen).setUseAutoload(Boolean.parseBoolean(RubyClientOptionsProvider.USE_AUTOLOAD_VALUE));
}
Expand Down
1 change: 1 addition & 0 deletions samples/client/echo_api/ruby-httpx/openapi_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.description = "Echo Server API"
s.license = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'httpx', '~> 1.0', '>= 1.0.0'

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/ruby-autoload/petstore.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
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 = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/ruby-faraday/petstore.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
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 = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
s.add_runtime_dependency 'faraday-multipart'
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/ruby-httpx/petstore.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
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 = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'httpx', '~> 1.0', '>= 1.0.0'

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/ruby/petstore.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
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 = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.description = "This specification shows how to use x-auth-id-alias extension for API keys."
s.license = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.description = "This specification shows how to use dynamic servers."
s.license = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.description = "This specification shows how to generate aliases to maps and arrays as models."
s.license = "Unlicense"
s.required_ruby_version = ">= 2.7"
s.metadata = {}

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

Expand Down