From e75962110a0261678064eab3905832ca0a3da3c2 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Wed, 19 Jul 2017 12:04:34 +0100 Subject: [PATCH 1/6] Convert String to &str in trait definition --- modules/swagger-codegen/src/main/resources/rust/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/rust/api.mustache b/modules/swagger-codegen/src/main/resources/rust/api.mustache index 0c59f7b8f53..4dbae6d6b81 100644 --- a/modules/swagger-codegen/src/main/resources/rust/api.mustache +++ b/modules/swagger-codegen/src/main/resources/rust/api.mustache @@ -24,7 +24,7 @@ impl {{{classname}}}Impl { pub trait {{classname}} { {{#operations}} {{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>; + fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{^isString}}{{{dataType}}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>; {{/operation}} {{/operations}} } From fa6cb0f9536935893d99dd0a4de08d046773aa03 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Wed, 19 Jul 2017 12:04:53 +0100 Subject: [PATCH 2/6] Only pass pathParams to uri builder --- modules/swagger-codegen/src/main/resources/rust/api.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/rust/api.mustache b/modules/swagger-codegen/src/main/resources/rust/api.mustache index 4dbae6d6b81..674f9d819d4 100644 --- a/modules/swagger-codegen/src/main/resources/rust/api.mustache +++ b/modules/swagger-codegen/src/main/resources/rust/api.mustache @@ -39,7 +39,7 @@ impl{{classname}} for {{classname}}Impl { 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()) @@ -47,7 +47,7 @@ impl{{classname}} for {{classname}}Impl { .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); From 9e4ae03f4b7e13933ddee991b381c058207b46a2 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Wed, 19 Jul 2017 12:05:12 +0100 Subject: [PATCH 3/6] Fixed the html escaping in return type --- modules/swagger-codegen/src/main/resources/rust/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/rust/api.mustache b/modules/swagger-codegen/src/main/resources/rust/api.mustache index 674f9d819d4..edffba8bc0d 100644 --- a/modules/swagger-codegen/src/main/resources/rust/api.mustache +++ b/modules/swagger-codegen/src/main/resources/rust/api.mustache @@ -77,7 +77,7 @@ impl{{classname}} for {{classname}}Impl { {{/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}} From 9bdb646d2861118a043fc235b37ddb8a06ab34a4 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Wed, 19 Jul 2017 12:05:21 +0100 Subject: [PATCH 4/6] Fixed the hashmap constructor --- modules/swagger-codegen/src/main/resources/rust/model.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/rust/model.mustache b/modules/swagger-codegen/src/main/resources/rust/model.mustache index 2ccc54e9234..3fe6089cd63 100644 --- a/modules/swagger-codegen/src/main/resources/rust/model.mustache +++ b/modules/swagger-codegen/src/main/resources/rust/model.mustache @@ -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}} } } From 3555d54780d5c2fed125dbf2b77c5f633476c3b9 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Wed, 19 Jul 2017 12:05:42 +0100 Subject: [PATCH 5/6] Added models into API scope --- .../swagger-codegen/src/main/resources/rust/api_mod.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/rust/api_mod.mustache b/modules/swagger-codegen/src/main/resources/rust/api_mod.mustache index 2516931e218..67ebae27b6d 100644 --- a/modules/swagger-codegen/src/main/resources/rust/api_mod.mustache +++ b/modules/swagger-codegen/src/main/resources/rust/api_mod.mustache @@ -19,7 +19,7 @@ impl From for Error { } } -use super::models; +use super::models::*; {{#apiInfo}} {{#apis}} From c142e460433ccad21fd2d2e31c1ea95d9adca91d Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Wed, 19 Jul 2017 12:13:53 +0100 Subject: [PATCH 6/6] removed models subimport, reference from super --- modules/swagger-codegen/src/main/resources/rust/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/rust/api.mustache b/modules/swagger-codegen/src/main/resources/rust/api.mustache index edffba8bc0d..98c1b12551f 100644 --- a/modules/swagger-codegen/src/main/resources/rust/api.mustache +++ b/modules/swagger-codegen/src/main/resources/rust/api.mustache @@ -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 { configuration: Rc>,