Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new version of rocket "0.5.0-rc.1" #7

Open
DoubleDebug opened this issue Jun 4, 2023 · 1 comment
Open

Support for new version of rocket "0.5.0-rc.1" #7

DoubleDebug opened this issue Jun 4, 2023 · 1 comment

Comments

@DoubleDebug
Copy link

Hello, thanks for this awesome Rust crate!
I have two questions:

  1. Does this crate support the latest version of rocket (version = "0.5.0-rc.1")? Using this version of rocket, my main function looks something like this:
#[launch]
fn rocket() -> _ {
  rocket
    ::build()
    .mount(
      "/docs",
      rocket_swagger_ui::routes(
        swagger_ui::swagger_spec_file!("../docs/openapi.json"),
        swagger_ui::Config { ..Default::default() }
      )
    )
}

Notice the difference from the example shown in your README file: the build instead of the ignite function. This produces the following error, which I don't know how to handle:

Rust swagger ui error

Is there currently a way to get around this error? If not, will it be supported in the future releases of swagger-ui?

  1. My apologies if the second question is stupid, but here it goes:

After downgrading my version of rocket to 4.7 (as demonstrated in your example), I managed to get the example running locally. However, when I open the http://localhost:8000/api/v1/swagger/index.html URL in my browser, it displays the PetStore API specification, even though I created and used my own openapi.json file in the code. What am I doing wrong?

I also tried specifying the file in the Config structure:

swagger_ui::Config { url: String::from("../docs/openapi.json"), ..Default::default() }
@wangjia184
Copy link

rocket 0.5.0 is out. I tried to upgrade rocket-swagger-ui but it fails on compilation.

error[E0432]: unresolved import `rocket::handler`
 --> rocket-swagger-ui\src\handlers.rs:1:13
  |
1 | use rocket::handler::{Handler, Outcome};
  |             ^^^^^^^ could not find `handler` in `rocket`

error[E0432]: unresolved import `rocket::response::Content`
 --> rocket-swagger-ui\src\handlers.rs:3:24
  |
3 | use rocket::response::{Content, Responder, Redirect};
  |                        ^^^^^^^
  |                        |
  |                        no `Content` in `response`
  |                        help: a similar name exists in the module (notice the capitalization): `content`

error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> rocket-swagger-ui\src\handlers.rs:9:30
    |
9   | pub struct ContentHandler<R: Responder<'static> + Clone + Send + Sync + 'static> {
    |                              ^^^^^^^^^ ------- supplied 1 lifetime argument
    |                              |
    |                              expected 2 lifetime arguments
    |
note: trait defined here, with 2 lifetime parameters: `'r`, `'o`
   --> .cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\rocket-0.5.0\src\response\responder.rs:293:11
    |
293 | pub trait Responder<'r, 'o: 'r> {
    |           ^^^^^^^^^ --  --
help: add missing lifetime argument
    |
9   | pub struct ContentHandler<R: Responder<'static, 'static> + Clone + Send + Sync + 'static> {
    |                                               +++++++++

error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> rocket-swagger-ui\src\handlers.rs:34:9
    |
34  | impl<R: Responder<'static> + Clone + Send + Sync + 'static> ContentHandler<R> {
    |         ^^^^^^^^^ ------- supplied 1 lifetime argument
    |         |
    |         expected 2 lifetime arguments
    |
note: trait defined here, with 2 lifetime parameters: `'r`, `'o`
   --> \.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\rocket-0.5.0\src\response\responder.rs:293:11
    |
293 | pub trait Responder<'r, 'o: 'r> {
    |           ^^^^^^^^^ --  --
help: add missing lifetime argument
    |
34  | impl<R: Responder<'static, 'static> + Clone + Send + Sync + 'static> ContentHandler<R> {
    |                          +++++++++

So it is incompatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants