Skip to content

Conversation

xitep
Copy link
Contributor

@xitep xitep commented Sep 7, 2025

I have two (or more) (openapi-)routers (from utoipa-axum) which both/all get nested into a top-level router using the same path prefix. (the reason is that i apply different (service) layers to the routers before assembling them.) however, while the axum router "merge" upon nesting works as expected, the openapi-router simply discards the old "paths" from openapi. this should correct the situation.

a possible workaround is:

let routes_1: OpenApiRouter = ...;
let routes_2: OpenApiRouter = ...;

let routes_1 = OpenApiRouter::default().nest("/foo", routes_1);
let routes_2 = OpenApiRouter::default().nest("/foo", routes_2);
let all_routes = routes1.merge(routes2);

or with vanilla utoipa:

        let mut all_routes = OpenApiBuilder::default()
            .build()
            .nest("/foo", routes1);
        routes.merge(
            OpenApiBuilder::default()
                .build()
                .nest("/foo", routes_2),
        );

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

Successfully merging this pull request may close these issues.

1 participant