ProbablyClem / utoipauto

Rust Macros to automate the addition of Paths/Schemas to Utoipa crate, simulating Reflection during the compilation phase
Apache License 2.0
108 stars 10 forks source link

Documentation improvement: Workspace usage #9

Closed DenuxPlays closed 7 months ago

DenuxPlays commented 7 months ago

I just keep getting this error: image

Here is the code that produces the error:

#[utoipauto(
    paths = "./src/controller/user.rs"
)]
#[derive(OpenApi)]
#[openapi(modifiers(&SecurityAddon))]
pub struct ApiDoc;

struct SecurityAddon;

impl Modify for SecurityAddon {
    fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
        match openapi.components {
            Some(_) => {}
            None => {
                openapi.components = Some(Components::default());
            }
        }
        openapi.components.as_mut().unwrap();
    }
}

Everything works fine when adding paths manually like utoipa intended.

DenuxPlays commented 7 months ago

Code can also be found here: https://github.com/financrr/backend/tree/main/backend

DenuxPlays commented 7 months ago

Found the error: Workspaces... Please add support for it. There is a "work-around":

Instead of doing "./src/controller/" you have to do "./backend/src/controller"

ProbablyClem commented 7 months ago

Hey, thanks for your feedback. I don't think they'll be a fix, since it's not really an issue. You have to specify the right path for it to work.

However, we probably need a documentation improvement to clarify this behaviour.

DenuxPlays commented 7 months ago

Hey, thanks for your feedback. I don't think they'll be a fix, since it's not really an issue. You have to specify the right path for it to work.

However, we probably need a documentation improvement to clarify this behaviour.

I can take care of this.