Skip to content

Commit

Permalink
Added mutable getter for the openapi instance of a OpenApiRouter (#1262)
Browse files Browse the repository at this point in the history
There is currently no way of changing the `OpenApi` without breaking the router apart and recomposing it.

This enables modification of the API while mounting the routes.
---------

Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
  • Loading branch information
zannabianca1997 and juhaku authored Jan 2, 2025
1 parent bd90d55 commit f09edbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions utoipa-axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changed

* Added mutable getter for the openapi instance of a OpenApiRouter (https://github.com/juhaku/utoipa/pull/1262)
* utoipa-axum: Add basic path params test (https://github.com/juhaku/utoipa/pull/1268)

## 0.1.3 - Dec 19 2024
Expand Down
5 changes: 5 additions & 0 deletions utoipa-axum/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ where
&self.1
}

/// Get mutable reference to the [`utoipa::openapi::OpenApi`] instance of the router.
pub fn get_openapi_mut(&mut self) -> &mut utoipa::openapi::OpenApi {
&mut self.1
}

/// Split the content of the [`OpenApiRouter`] to parts. Method will return a tuple of
/// inner [`axum::Router`] and [`utoipa::openapi::OpenApi`].
pub fn split_for_parts(self) -> (axum::Router<S>, utoipa::openapi::OpenApi) {
Expand Down

0 comments on commit f09edbe

Please sign in to comment.