Description
I am trying to build Rust bindings for EVE Online's ESI EVE Swagger Interface. Unfortunately, lists in parameters aren't always being handled correctly. Specifically, the generated API code tries to apply join(",") to Vecs of various incompatible types, including i32 and Vec<i32>.
Swagger-codegen version
I have tried with multiple versions; all seem to generate the same code. I am currently working with master from Git (f6fca7640 2018-05-03).
Swagger declaration file content or url
https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility
Command line used for generation
java -jar swagger-codegen-cli.jar generate
-i https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility
-l rust
--invoker-package esi
--api-package esi
--model-package esi
-DpackageName=esi
-o .
Steps to reproduce
Run the generator as described above. cargo build (any recent Rust version).
Related issues/PRs
None found.
Suggest a fix/enhancement
I've started to fix this: the following gross-hack patch to api.mustache gets all the cases for Vec<i32> and the like.
diff --git a/modules/swagger-codegen/src/main/resources/rust/api.mustache b/modules/swagger-codegen/src/main/resources/rust/api.mustache
index 55604ca79..ab6c69334 100644
--- a/modules/swagger-codegen/src/main/resources/rust/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/rust/api.mustache
@@ -87,7 +87,7 @@ impl<C: hyper::client::Connect>{{classname}} for {{classname}}Client<C> {
let query_string = {
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
{{#queryParams}}
- query.append_pair("{{baseName}}", &{{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
+ query.append_pair("{{baseName}}", &{{paramName}}{{#isListContainer}}.iter().map(|v| v.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string());
{{/queryParams}}
{{#hasAuthMethods}}
for (key, val) in &auth_query {
Unfortunately in one case (/route/<origin>/<destination>) a parameter is a list of pairs, which gets translated to a list of lists i.e. Vec<Vec<i32>> which still fails to join(). I could conceivably kludge around this, but it seems like someone with a better understanding of the mustache templating being used here could put some more principled fix in place.
Description
I am trying to build Rust bindings for EVE Online's ESI EVE Swagger Interface. Unfortunately, lists in parameters aren't always being handled correctly. Specifically, the generated API code tries to apply
join(",")toVecs of various incompatible types, includingi32andVec<i32>.Swagger-codegen version
I have tried with multiple versions; all seem to generate the same code. I am currently working with master from Git (
f6fca76402018-05-03).Swagger declaration file content or url
https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility
Command line used for generation
java -jar swagger-codegen-cli.jar generate
-i https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility
-l rust
--invoker-package esi
--api-package esi
--model-package esi
-DpackageName=esi
-o .
Steps to reproduce
Run the generator as described above.
cargo build(any recent Rust version).Related issues/PRs
None found.
Suggest a fix/enhancement
I've started to fix this: the following gross-hack patch to
api.mustachegets all the cases forVec<i32>and the like.Unfortunately in one case (
/route/<origin>/<destination>) a parameter is a list of pairs, which gets translated to a list of lists i.e.Vec<Vec<i32>>which still fails tojoin(). I could conceivably kludge around this, but it seems like someone with a better understanding of the mustache templating being used here could put some more principled fix in place.