GREsau / okapi

OpenAPI (AKA Swagger) document generation for Rust projects
MIT License
578 stars 103 forks source link

Compile error. #103

Closed JYInMyHeart closed 2 years ago

JYInMyHeart commented 2 years ago

Rocket_okapi gives me some errors when I try to use it.

error[E0432]: unresolved import `rocket::response::content::Custom`
use rocket::response::{content::Custom, Responder};
  |                        ^^^^^^^^^^^^^^^ no `Custom` in `response::content`

Could you please release rocket_okapi v0.8.0-rc.2?

mbledkowski commented 2 years ago

Same issue for me

   Compiling rocket_okapi v0.8.0-rc.1
error[E0432]: unresolved import `rocket::response::content::Custom`
 --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/handlers/content.rs:2:24
  |
2 | use rocket::response::{content::Custom, Responder};
  |                        ^^^^^^^^^^^^^^^ no `Custom` in `response::content`

error[E0432]: unresolved import `rocket::response::content::Custom`
 --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/handlers/openapi.rs:3:5
  |
3 | use rocket::response::content::Custom;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Custom` in `response::content`

error[E0412]: cannot find type `Css` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:216:27
    |
216 | response_content_wrapper!(Css, "text/css");
    |                           ^^^ not found in `rocket::response::content`

error[E0412]: cannot find type `Custom` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:217:27
    |
217 | response_content_wrapper!(Custom, "*/*");
    |                           ^^^^^^ not found in `rocket::response::content`
    |
help: consider importing this struct
    |
1   | use rocket::response::status::Custom;
    |

error[E0412]: cannot find type `Html` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:218:27
    |
218 | response_content_wrapper!(Html, "text/html");
    |                           ^^^^ not found in `rocket::response::content`

error[E0412]: cannot find type `JavaScript` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:219:27
    |
219 |   response_content_wrapper!(JavaScript, "application/javascript");
    |                             ^^^^^^^^^^ help: a struct with a similar name exists: `RawJavaScript`
    |
   ::: /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.5.0-rc.2/src/response/content.rs:69:1
    |
69  | / ctrs! {
70  | |     // FIXME: Add a note that this is _not_ `serde::Json`.
71  | |     RawJson: JSON, "JSON", "application/json",
72  | |     RawXml: XML, "XML", "text/xml",
...   |
77  | |     RawJavaScript: JavaScript, "JavaScript", "application/javascript"
78  | | }
    | |_- similarly named struct `RawJavaScript` defined here

error[E0412]: cannot find type `Json` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:220:27
    |
220 | response_content_wrapper!(Json, "application/json");
    |                           ^^^^ not found in `rocket::response::content`
    |
help: consider importing this struct
    |
1   | use rocket::serde::json::Json;
    |

error[E0412]: cannot find type `MsgPack` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:221:27
    |
221 | response_content_wrapper!(MsgPack, "application/msgpack");
    |                           ^^^^^^^ not found in `rocket::response::content`

error[E0412]: cannot find type `Plain` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:222:27
    |
222 | response_content_wrapper!(Plain, "text/plain");
    |                           ^^^^^ not found in `rocket::response::content`

error[E0412]: cannot find type `Xml` in module `rocket::response::content`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/response/responder_impls.rs:223:27
    |
223 | response_content_wrapper!(Xml, "text/xml");
    |                           ^^^ not found in `rocket::response::content`

error[E0283]: type annotations needed
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/swagger_ui.rs:136:24
    |
136 |         config_handler.into_route("/swagger-ui-config.json"),
    |                        ^^^^^^^^^^ cannot infer type for type parameter `R`
    |
    = note: cannot satisfy `_: AsRef<[u8]>`
note: required by a bound in `handlers::content::ContentHandler::<R>::into_route`
   --> /home/mble/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_okapi-0.8.0-rc.1/src/handlers/content.rs:44:9
    |
44  | impl<R: AsRef<[u8]> + Clone + Send + Sync + 'static> ContentHandler<R> {
    |         ^^^^^^^^^^^ required by this bound in `handlers::content::ContentHandler::<R>::into_route`
45  |     /// Create a `rocket::Route` from the current `ContentHandler`.
46  |     pub fn into_route(self, path: impl AsRef<str>) -> Route {
    |            ---------- required by a bound in this

Some errors have detailed explanations: E0283, E0412, E0432.
For more information about an error, try `rustc --explain E0283`.
error: could not compile `rocket_okapi` due to 11 previous errors
JYInMyHeart commented 2 years ago

@mbledkowski I fixed it by adding other version of rocket_okapi. This is my Cargo.toml.

rocket_okapi = { git = "https://github.com/GREsau/okapi.git", branch = "master" ,features = ["swagger", "rapidoc"]}
mbledkowski commented 2 years ago

@JYInMyHeart thank you very much, it is now working for me <3

ralpha commented 2 years ago

New versions have been published to crates.io https://crates.io/crates/rocket_okapi/0.8.0-rc.2 (best update dependencies to crates.io version instead of master branch)

rocket_okapi = { version = "0.8.0-rc.2", features = ["..."]}

All feature flags can be found here: https://github.com/GREsau/okapi/#feature-flags