Instead, you will have to use a regex with no lookaheads and manually remove the trailing slash: #[OpenApi] impl Api { #[oai(path = "/:namespace<.+/>:id", method = "get")] async fn get( &self, ... namespace: Path<String>, id: Path<String>, ) -> ... { // GET /a/...