netwo-io/apistos

Incorrect Usage of ResponseWrapper Instead of ResponderWrapper

darkyeg opened this issue · 3 comments

In the provided code snippet, there appears to be a typo in the usage of the type ResponseWrapper. It seems that ResponseWrapper should actually be ResponderWrapper according to the context.

Here's the corrected snippet:

if string_type == "impl Responder" {
    is_responder = true;

    *_type = Box::new(
        match syn::parse2(quote!(
            impl std::future::Future<Output=apistos::actix::ResponderWrapper<#_type>>
        )) {
            Ok(parsed) => parsed,
            Err(e) => abort!("parsing impl trait: {:?}", e),
        },
    );
}

https://github.com/netwo-io/apistos/blob/main/apistos-gen/src/internal/mod.rs#L153

Hi, thanks for the report.

Did you encounter any bug due to this ?
I will investigate the impact of the change.

Hi, thanks for the report.

Did you encounter any bug due to this ? I will investigate the impact of the change.

#[api_operation]
async fn test() -> impl Responder {
  HttpResponse::Ok()
}
error[E0423]: expected function, tuple struct or tuple variant, found struct `apistos::actix::ResponseWrapper`
   |
15 | #[api_operation]
   | ^^^^^^^^^^^^^^^^
   |
   |
13 | pub struct ResponseWrapper<R, P> {
   | -------------------------------- `apistos::actix::ResponseWrapper` defined here
...
59 | pub struct ResponderWrapper<T>(pub T);
   | ------------------------------ similarly named tuple struct `ResponderWrapper` defined here
   |
   = note: this error originates in the attribute macro `api_operation` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use struct literal syntax instead
   |
15 | apistos::actix::ResponseWrapper { inner: val, path_item: val }
   |
help: a tuple struct with a similar name exists
   |
15 | ResponderWrapper

Fix has been merged and will be available with version 0.2.1.
Thanks for the report !