Skip to content

Commit

Permalink
Add merge_from method for chainable merge (#924)
Browse files Browse the repository at this point in the history
Add new method `merge_from` for `OpenApi` to provide better chainability
when merging multiple `OpenApi`s to a single one.
  • Loading branch information
juhaku authored May 14, 2024
1 parent 2661057 commit 86339ec
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utoipa/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ impl OpenApi {
serde_yaml::to_string(self)
}

/// Merge `other` [`OpenApi`] moving `self` and returning combined [`OpenApi`].
///
/// In functionality wise this is exactly same as calling [`OpenApi::merge`] but but provides
/// leaner API for chaining method calls.
pub fn merge_from(mut self, other: OpenApi) -> OpenApi {
self.merge(other);
self
}

/// Merge `other` [`OpenApi`] consuming it and resuming it's content.
///
/// Merge function will take all `self` nonexistent _`servers`, `paths`, `schemas`, `responses`,
Expand Down

0 comments on commit 86339ec

Please sign in to comment.