diff --git a/docs/generators/ruby.md b/docs/generators/ruby.md index e837c7b97c4..46a61d42738 100644 --- a/docs/generators/ruby.md +++ b/docs/generators/ruby.md @@ -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| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java index 18127e4fa8b..0973688599a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java @@ -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"; @@ -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/"; @@ -170,6 +172,9 @@ public class RubyClientCodegen extends AbstractRubyCodegen { 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())); @@ -246,6 +251,10 @@ public class RubyClientCodegen extends AbstractRubyCodegen { 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)); } @@ -613,6 +622,10 @@ public class RubyClientCodegen extends AbstractRubyCodegen { this.gemAuthorEmail = gemAuthorEmail; } + public void setGemMetadata(String gemMetadata) { + this.gemMetadata = gemMetadata; + } + public void setUseAutoload(boolean useAutoload) { this.useAutoload = useAutoload; } diff --git a/modules/openapi-generator/src/main/resources/ruby-client/gemspec.mustache b/modules/openapi-generator/src/main/resources/ruby-client/gemspec.mustache index 8fba4b4efd1..3e4b613face 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/gemspec.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/gemspec.mustache @@ -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' diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/RubyClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/RubyClientOptionsProvider.java index 45a656dd3c3..4578b058af7 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/RubyClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/RubyClientOptionsProvider.java @@ -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"; @@ -61,6 +62,7 @@ public class RubyClientOptionsProvider implements OptionsProvider { .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) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientOptionsTest.java index 7f600322de6..0fe6656cce9 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientOptionsTest.java @@ -50,6 +50,7 @@ public class RubyClientOptionsTest extends AbstractOptionsTest { 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)); } diff --git a/samples/client/echo_api/ruby-httpx/openapi_client.gemspec b/samples/client/echo_api/ruby-httpx/openapi_client.gemspec index d479c1892b0..be7e85fd87b 100644 --- a/samples/client/echo_api/ruby-httpx/openapi_client.gemspec +++ b/samples/client/echo_api/ruby-httpx/openapi_client.gemspec @@ -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' diff --git a/samples/client/petstore/ruby-autoload/petstore.gemspec b/samples/client/petstore/ruby-autoload/petstore.gemspec index d5420ccb8be..f30188db07b 100644 --- a/samples/client/petstore/ruby-autoload/petstore.gemspec +++ b/samples/client/petstore/ruby-autoload/petstore.gemspec @@ -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' diff --git a/samples/client/petstore/ruby-faraday/petstore.gemspec b/samples/client/petstore/ruby-faraday/petstore.gemspec index 7540e70134b..08519bf307e 100644 --- a/samples/client/petstore/ruby-faraday/petstore.gemspec +++ b/samples/client/petstore/ruby-faraday/petstore.gemspec @@ -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' diff --git a/samples/client/petstore/ruby-httpx/petstore.gemspec b/samples/client/petstore/ruby-httpx/petstore.gemspec index 403ec03e1bd..f6bc239af5b 100644 --- a/samples/client/petstore/ruby-httpx/petstore.gemspec +++ b/samples/client/petstore/ruby-httpx/petstore.gemspec @@ -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' diff --git a/samples/client/petstore/ruby/petstore.gemspec b/samples/client/petstore/ruby/petstore.gemspec index d5420ccb8be..f30188db07b 100644 --- a/samples/client/petstore/ruby/petstore.gemspec +++ b/samples/client/petstore/ruby/petstore.gemspec @@ -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' diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/x_auth_id_alias.gemspec b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/x_auth_id_alias.gemspec index c4a502db685..37580c2b500 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/x_auth_id_alias.gemspec +++ b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/x_auth_id_alias.gemspec @@ -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' diff --git a/samples/openapi3/client/features/dynamic-servers/ruby/dynamic_servers.gemspec b/samples/openapi3/client/features/dynamic-servers/ruby/dynamic_servers.gemspec index 4c0134d4e5e..b715b4fc82e 100644 --- a/samples/openapi3/client/features/dynamic-servers/ruby/dynamic_servers.gemspec +++ b/samples/openapi3/client/features/dynamic-servers/ruby/dynamic_servers.gemspec @@ -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' diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/petstore.gemspec b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/petstore.gemspec index 3b537846b36..53ebbfc5a28 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/petstore.gemspec +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/petstore.gemspec @@ -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'