update ruby readme template

This commit is contained in:
wing328 2018-04-09 11:01:01 +08:00
parent a08164592a
commit c1e7da5ec1
3 changed files with 12 additions and 44 deletions

View File

@ -294,42 +294,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
*/ */
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
// Set vendor-extension to be used in template:
// x-codegen-hasMoreRequired
// x-codegen-hasMoreOptional
// x-codegen-hasRequiredParams
CodegenParameter lastRequired = null;
CodegenParameter lastOptional = null;
for (CodegenParameter p : op.allParams) {
if (p.required) {
lastRequired = p;
} else {
lastOptional = p;
}
}
for (CodegenParameter p : op.allParams) {
if (p == lastRequired) {
p.vendorExtensions.put("x-codegen-hasMoreRequired", false);
} else if (p == lastOptional) {
p.vendorExtensions.put("x-codegen-hasMoreOptional", false);
} else {
p.vendorExtensions.put("x-codegen-hasMoreRequired", true);
p.vendorExtensions.put("x-codegen-hasMoreOptional", true);
}
}
op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null);
}
return objs;
}
@Override @Override
public CodegenType getTag() { public CodegenType getTag() {
return CodegenType.CLIENT; return CodegenType.CLIENT;

View File

@ -76,13 +76,19 @@ require '{{{gemName}}}'
{{/authMethods}}end {{/authMethods}}end
{{/hasAuthMethods}} {{/hasAuthMethods}}
api_instance = {{{moduleName}}}::{{{classname}}}.new{{#hasParams}} api_instance = {{{moduleName}}}::{{{classname}}}.new
{{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} {{#requiredParams}}
{{{paramName}}} = {{{example}}} # {{{dataType}}} | {{{description}}} {{{paramName}}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{/required}}{{/allParams}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} {{/requiredParams}}
opts = { {{#allParams}}{{^required}} {{#optionalParams}}
{{{paramName}}}: {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} # {{{dataType}}} | {{{description}}}{{/required}}{{/allParams}} {{#-first}}
}{{/hasOptionalParams}}{{/hasParams}} opts = {
{{/-first}}
{{{paramName}}}: {{{example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
{{#-last}}
}
{{/-last}}
{{/optionalParams}}
begin begin
{{#summary}} #{{{.}}} {{#summary}} #{{{.}}}

View File

@ -55,10 +55,8 @@ Please follow the [installation](#installation) procedure and then run the follo
require 'petstore' require 'petstore'
api_instance = Petstore::AnotherFakeApi.new api_instance = Petstore::AnotherFakeApi.new
client = Petstore::Client.new # Client | client model client = Petstore::Client.new # Client | client model
begin begin
#To test special tags #To test special tags
result = api_instance.test_special_tags(client) result = api_instance.test_special_tags(client)