unexpected attribute "openapi" "paths" macro #249
-
Hi, I am trying to get utoipa to work with the provided actix examples and i am running into an error with the openapi macro. When i try to build the project i get an error:
Any ideas why this is happening and how to fix it? FilesCargo.toml: [dependencies]
actix-web = "4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.9.0"
log = "0.4"
futures = "0.3"
utoipa = { version= "1", features = ["actix_extras"] }
utoipa-swagger-ui = { version= "1", features = ["actix-web"] } main.rs use std::{error::Error, net::Ipv4Addr};
use actix_web::{middleware::Logger, web, App, HttpServer};
use utoipa::OpenApi;
use utoipa_swagger_ui::{SwaggerUi, Url};
#[actix_web::main]
async fn main() -> Result<(), impl Error> {
env_logger::init();
#[derive(OpenApi)]
#[openapi(paths(apiv1::hello1))]
struct ApiDocV1;
HttpServer::new(move || {
App::new()
.wrap(Logger::default())
.service(
web::scope("/api")
.service(apiv1::hello1)
)
.service(SwaggerUi::new("/swagger-ui/{_:.*}").urls(vec![
(
Url::new("api1", "/api-doc/openapi1.json"),
ApiDocV1::openapi(),
)
]))
})
.bind((Ipv4Addr::UNSPECIFIED, 8080))?
.run()
.await
}
mod apiv1 {
use actix_web::get;
#[utoipa::path(
context_path = "/api",
responses(
(status = 200, description = "Hello from api 1", body = String)
)
)]
#[get("/v1/hello")]
pub(super) async fn hello1() -> String {
"hello from api 1".to_string()
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, Actually the syntax available in the examples and in README is for the next release 2.0.0 which is not available in 1.1 from crates. The next release should be available in not distant future. Here is the Github link to the latest release: https://github.com/juhaku/utoipa/tree/utoipa-1.1.0. Alternatively you can use git as source for the dependency to get the latest version for you according this: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories |
Beta Was this translation helpful? Give feedback.
Hi,
Actually the syntax available in the examples and in README is for the next release 2.0.0 which is not available in 1.1 from crates. The next release should be available in not distant future.
Here is the Github link to the latest release: https://github.com/juhaku/utoipa/tree/utoipa-1.1.0.
Alternatively you can use git as source for the dependency to get the latest version for you according this: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories