google-apis-rs / generator

A binding and CLI generator for all google APIs
Apache License 2.0
71 stars 14 forks source link

Repeated method parameters not working #29

Open appaquet opened 3 years ago

appaquet commented 3 years ago

Hi,

When trying to use a rest api method's param that supports repeated values (i.e. Vec<T>), it fails at runtime as reqwest expects repeated fields to be passed in a &[(param, value1), (param, value2)] format instead of &[(param, values)] format (see reqwest's request.rs).

Example: In Gmail's list threads request, for parameter label_ids of type Vec<String>, it is passed as-is to reqwest query: https://github.com/google-apis-rs/generated/blob/master/gen/gmail/v1/lib/src/lib.rs#L8537

I tried to dig down on how the generator generates the method. As I understand it, it would need to remap repeated parameters to reqwest expected format in here: https://github.com/google-apis-rs/generator/blob/a848301466556f16d48df64ef16b92a8327a8406/google_rest_api_generator/src/method_builder.rs#L368

Let me know if you need more info. I'm willing to take a stab at it if you can describe how you envision the fix.

Thanks !

ggriffiniii commented 3 years ago

Thanks for the report. You're correct about the location in the generator that needed to be fixed. https://github.com/google-apis-rs/generator/commit/9ad1f063e5046f2f404ea77f0116e0fd25b4246d should have the fix. @mwilliammyers Would you mind regenerating the bindings whenever you get a chance?

mwilliammyers commented 3 years ago

I tried generating it again but ran into some issues, so I will try again later when I have more time to fix the issues.

doivosevic commented 3 years ago

Hey guys! Any progress on this?

mwilliammyers commented 3 years ago

@doivosevic Sorry for the late response, I updated them all in google-apis-rs/generated@318cd3b1. All of the libs build, but many of the CLI bins do not.