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
10 changes: 5 additions & 5 deletions modules/swagger-codegen/src/main/resources/rust/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde_json;
use futures;
use futures::{Future, Stream};

use super::{Error, configuration, models};
use super::{Error, configuration};

pub struct {{{classname}}}Impl<C: hyper::client::Connect> {
configuration: Rc<configuration::Configuration<C>>,
Expand All @@ -24,7 +24,7 @@ impl<C: hyper::client::Connect> {{{classname}}}Impl<C> {
pub trait {{classname}} {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error = Error>>;
fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{^isString}}{{{dataType}}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error = Error>>;
{{/operation}}
{{/operations}}
}
Expand All @@ -39,15 +39,15 @@ impl<C: hyper::client::Connect>{{classname}} for {{classname}}Impl<C> {
let method = hyper::Method::{{httpMethod}};

{{^hasQueryParams}}
let uri = format!("{}{{{path}}}", configuration.base_path{{#allParams}}, "{{baseName}}"={{paramName}}{{/allParams}}));
let uri = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{baseName}}={{paramName}}{{/pathParams}});
{{/hasQueryParams}}
{{#hasQueryParams}}
let query = url::form_urlencoded::Serializer::new(String::new())
{{#queryParams}}
.append_pair("{{baseName}}", {{paramName}})
{{/queryParams}}
.finish();
let uri = format!("{}{{{path}}}{}", configuration.base_path, query{{#allParams}}, "{{baseName}}"={{paramName}}{{/allParams}}));
let uri = format!("{}{{{path}}}{}", configuration.base_path, query{{#pathParams}}, {{baseName}}={{paramName}}{{/pathParams}});
{{/hasQueryParams}}

let mut req = hyper::Request::new(method, uri);
Expand Down Expand Up @@ -77,7 +77,7 @@ impl<C: hyper::client::Connect>{{classname}} for {{classname}}Impl<C> {
{{/returnType}}
{{#returnType}}
.and_then(|body| {
let parsed: Result<{{returnType}}, _> = serde_json::from_slice(&body);
let parsed: Result<{{{returnType}}}, _> = serde_json::from_slice(&body);
parsed.map_err(|e| Error::from(e))
}).map_err(|e| Error::from(e))
{{/returnType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl From<serde_json::Error> for Error {
}
}

use super::models;
use super::models::*;

{{#apiInfo}}
{{#apis}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl {{classname}} {
pub fn new({{#requiredVars}}{{name}}: {{{datatype}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{classname}} {
{{classname}} {
{{#vars}}
{{name}}: {{#required}}{{name}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}Hash:new(){{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
{{name}}: {{#required}}{{name}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}HashMap::new(){{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
{{/vars}}
}
}
Expand Down