forked from loafle/openapi-generator-original
[Ruby] Add support for populating a gem metadata (#16872)
* [Ruby] Add support for gems metadata This defaults to an empty hash, but can be overridden with any custom object by the callers via the `gemMetadata` property. * Regenerate samples The gemspecs files will now include a metadata field
This commit is contained in:
parent
f16744a2bb
commit
ae590c4712
@ -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|
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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'
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user