google-apis-rs / generator

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

Pubsub subscription delete - Incorrect response type #16

Open binarybana opened 5 years ago

binarybana commented 5 years ago

When trying to delete a pubsub subscription using latest master of the generated/gen/pubsub/v1/lib crate:

client
            .projects()
            .subscriptions()
            .delete(SUBSCRIPTION_NAME)
            .execute_with_default_fields()?;

Returns an error like this:

'Couldn't convert to json: Error(Json(Error("invalid type: map, expected unit struct Empty", line: 1, column: 0)))'

With a snipped stack trace of:

  10: core::result::unwrap_failed
             at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/macros.rs:18
  11: core::result::Result<T,E>::expect
             at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/result.rs:827
  12: google_pubsub1::resources::projects::subscriptions::DeleteRequestBuilder::_execute
             at /Users/jason/src/generated/gen/pubsub/v1/lib/src/lib.rs:3863
  13: google_pubsub1::resources::projects::subscriptions::DeleteRequestBuilder::execute_with_fields
             at /Users/jason/src/generated/gen/pubsub/v1/lib/src/lib.rs:3853
  14: google_pubsub1::resources::projects::subscriptions::DeleteRequestBuilder::execute_with_default_fields
             at /Users/jason/src/generated/gen/pubsub/v1/lib/src/lib.rs:3830
  15: gcp_utils::pubsub::tests::init
             at gcp-utils/src/pubsub.rs:21

(the line numbers may not match exactly because I inserted a few lines of debugging help)

Whereas the actual reqwest response that comes back is successful:

Response { url: "https://pubsub.googleapis.com/v1/projects/octomizer/subscriptions/test-subscription-21990", status: 200, headers: {"content-type": "application/json; charset=UTF-8", "vary": "Origin", "vary": "X-Origin", "vary": "Referer", "transfer-encoding": "chunked", "date": "Fri, 20 Sep 2019 17:20:57 GMT", "server": "ESF", "cache-control": "private", "x-xss-protection": "0", "x-frame-options": "SAMEORIGIN", "x-content-type-options": "nosniff", "alt-svc": "quic=\":443\"; ma=2592000; v=\"46,43,39\""} }test pubsub::tests::publish_and_poll_message

It looks like the Ok variant return type of pubsub::v1::lib::DeleteRequestBuilder::execute_with_default_fields is wrongly set to Empty:

                pub fn execute_with_default_fields(
                    self,
                ) -> Result<crate::schemas::Empty, crate::Error> {

But I'm not sure what it should be set to?

If I instead use execute_with_fields(Some("*")) instead of execute_with_default_fields I can work around it, but I need to add an extra .map(|_: serde_json::Value| ()); on the end to help type inference (I'm assuming).

binarybana commented 5 years ago

I also just hit this for client.projects().subscriptions().acknowledge(... as well.

ggriffiniii commented 5 years ago

I pushed https://github.com/google-apis-rs/generator/commit/aa0890541a82330db7abd5d54c92c400825e8094, which should fix the generator if I understand the issue correctly. I'm not very familiar with how to regenerate the apis in the generated directory unfortunately. I just tried a number of things, but they failed with errors (which sadly matches all my previous experiences). @Byron will know how to regenerate those libs when he sees this.

Byron commented 5 years ago

I have regenerated all APIs with just refresh-all, and I hope it helps, @binarybana .

Besides that, maybe @ggriffiniii could give me a hint to be able to fix whatever issue is preventing you from doing the same.

Thanks everyone for the enthusiasm :), I can't wait to see this iteration of google-apis-rs in its full async glory!