better struct alias in rust (#6470)

This commit is contained in:
William Cheng 2020-05-29 13:13:08 +08:00 committed by GitHub
parent 52fcdd5974
commit 7cef7b7591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ impl {{{classname}}}Client {
{{#-first}}
/// struct for passing parameters to the method `{{operationId}}`
#[derive(Clone, Debug)]
pub struct {{{classname}}}{{{operationIdCamelCase}}}Params {
pub struct {{{operationIdCamelCase}}}Params {
{{/-first}}
{{#description}}
/// {{{.}}}
@ -49,7 +49,7 @@ pub trait {{{classname}}} {
{{#operations}}
{{#operation}}
{{#vendorExtensions.x-group-parameters}}
fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{classname}}}{{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
{{/vendorExtensions.x-group-parameters}}
{{^vendorExtensions.x-group-parameters}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
@ -63,7 +63,7 @@ impl {{{classname}}} for {{{classname}}}Client {
{{#operations}}
{{#operation}}
{{#vendorExtensions.x-group-parameters}}
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{classname}}}{{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
// unbox the parameters
{{#allParams}}
let {{paramName}} = params.{{paramName}};

View File

@ -46,7 +46,7 @@ pub use self::{{{classFilename}}}::{ {{{operationId}}} };
{{#vendorExtensions.x-group-parameters}}
{{#allParams}}
{{#-first}}
pub use self::{{{classFilename}}}::{ {{{classname}}}{{{operationIdCamelCase}}}Params };
pub use self::{{{classFilename}}}::{{{operationIdCamelCase}}} as {{{classname}}}{{{operationIdCamelCase}}};
{{/-first}}
{{/allParams}}
{{/vendorExtensions.x-group-parameters}}