Skip to content

Incorrect path using by swagger-ui #1298

@Desiders

Description

@Desiders

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions