-
Notifications
You must be signed in to change notification settings - Fork 9
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
Components lack full module paths #2
Comments
Hey, |
Here's the code with just utoipa: |
I fixed it in 0.1.3 |
It seems that you have your paths both in src/routing/api//audio.rs and in main.rs ... |
mod routing;
mod services;
use routing::main_route;
use services::{
database::{files::FileStorage, surreal::SurrealDb},
runner::run,
};
use crate::services::{app::AppState, config::setup_config, tracing::setup_tracing};
#[tokio::main]
async fn main() {
let config = setup_config();
setup_tracing(&config.tracing);
let auth_keys = (&config.auth_keys).try_into().expect("Missing PEMs");
let surreal_db = SurrealDb::setup(&config.surreal_db)
.await
.expect("Failed to setup SurrealDb");
let file_storage = FileStorage::setup(&config.file_storage)
.await
.expect("Failed to setup FileStorage");
let state = AppState {
auth_keys,
surreal_db,
file_storage,
};
run(config.app.url, main_route(&config).with_state(state)).await;
}
#[cfg(test)]
mod tests {
use std::fs::OpenOptions;
use crate::routing;
use crate::services;
use utoipa::OpenApi;
use utoipauto::utoipauto;
#[test]
fn make_openapi_json() {
#[utoipauto] // <===== Error here
#[derive(OpenApi)]
#[openapi(
tags(
(name = "todo", description = "chghckgj")
)
)]
pub struct ApiDoc;
let file = OpenOptions::new()
.write(true)
.truncate(true)
.create(true)
.open("openapi.json")
.unwrap();
serde_json::to_writer_pretty(file, &ApiDoc::openapi()).unwrap();
}
} This is the entire |
Here, I posted this exact version on a branch for easier testing: |
Yeah you don't need to use since it's supposed to add the function with the full path |
#[utoipa::path(
post,
path = "/audio/delete",
responses(
(status = 200, description = "Delete listed audio samples successfully", body = DeleteSamplesRequest)
)
)]
async fn delete_audio( <==== Add pub
audio_repo: AudioRepository,
_: Claims,
ValidatedJson(data): ValidatedJson<DeleteSamplesRequest>,
) -> ResponseType<()> {
let Ok(_) = audio_repo
.delete_samples(data.ids)
.await
.map_err(|e| error!({error = ?e}, "Encountered an error while deleting a sample"))
else {
return ResponseType::Status(StatusCode::INTERNAL_SERVER_ERROR);
};
ResponseType::Status(StatusCode::OK)
} I think the issue is that your handler are not public, which means they can't be used outside ou the module |
I've made everything that could be public public, doesn't seem to fix it :( |
Hello, we're trying out this crate for a college assignment involving a backend server.
We've setup the project to use just
utoipa
then proceeded to replace the declarations with this crate's macro.The derived components seem to lack the module path, so instead of
crate::routing::api::audio::DeleteSamplesRequest
the macro generates justDeleteSamplesRequest
. And so it asks us to import it, as well as every other missing model.This is the error
Intuition is telling me, the components should be added with the full paths. Not sure if this is a problem by design.
There are few examples where paths are added to the macro, but I don't think that's our use case. Do let me know if I'm doing something wrong.
The text was updated successfully, but these errors were encountered: