Skip to content

Commit

Permalink
Sort operations before building spec to ensure same order in spec reg…
Browse files Browse the repository at this point in the history
…ardless of the order they added to router
  • Loading branch information
Flowneee committed Jul 24, 2024
1 parent 3d25438 commit f90ccde
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions okapi-operation/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ impl OpenApiBuilder {
pub fn build(&mut self) -> Result<OpenApi, anyhow::Error> {
let mut spec = self.spec.clone();

self.operations.sort_by(|lkey, _, rkey, _| {
let lkey_str = (&lkey.0, lkey.1.as_str());
let rkey_str = (&rkey.0, rkey.1.as_str());
lkey_str.cmp(&rkey_str)
});

for ((path, method), generator) in &self.operations {
try_add_path(
&mut spec,
Expand Down

0 comments on commit f90ccde

Please sign in to comment.