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

Incorrect path using by swagger-ui #1298

Open
Desiders opened this issue Jan 23, 2025 · 1 comment
Open

Incorrect path using by swagger-ui #1298

Desiders opened this issue Jan 23, 2025 · 1 comment

Comments

@Desiders
Copy link

I have two endpoints where each of them in the own module, and they have equal names, so we need to join them by nest:

mod first {
    use utoipa::OpenApi;

    #[derive(OpenApi)]
    #[openapi(paths(get))]
    pub struct Doc;

    #[utoipa::path(get, path = "")]
    pub async fn get() -> &'static str {
        "First"
    }
}

mod second {
    use utoipa::OpenApi;

    #[derive(OpenApi)]
    #[openapi(paths(get))]
    pub struct Doc;

    #[utoipa::path(get, path = "")]
    pub async fn get() -> &'static str {
        "Second"
    }
}

#[derive(OpenApi)]
#[openapi(
    nest(
        (path = "/second", api = second::Doc),
        (path = "/first", api = first::Doc),
    ),
)]
pub struct ApiDoc;

I open /swagger endpoint and use /second, but it calls /first, what is incorrect, so I tried to do so with RapiDoc and it doesn't have the problem.

I created an example to demonstrate that correct utoipa usage with axum leads to incorrect UI in Swagger.

@Desiders
Copy link
Author

Changing the name of one of the endpoints solves the problem

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

1 participant