Skip to content

Commit

Permalink
Make operation ids URL-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez committed Oct 4, 2023
1 parent 698be88 commit ada969a
Show file tree
Hide file tree
Showing 2 changed files with 333 additions and 322 deletions.
13 changes: 12 additions & 1 deletion openapi-converter/clients_schema_to_openapi/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

use std::collections::HashMap;
use std::fmt::Write;
use anyhow::{anyhow, bail};
use indexmap::indexmap;

Expand Down Expand Up @@ -260,7 +261,17 @@ pub fn add_endpoint(endpoint: &clients_schema::Endpoint, tac: &mut TypesAndCompo
};

let mut operation = operation.clone();
operation.operation_id = Some(format!("{}#{}", endpoint.name, operation_counter));
let mut operation_id: String = endpoint.name
.chars()
.map(|x| match x {
'_' | '.' => '-',
_ => x
}).collect();
if operation_counter != 0 {
write!(&mut operation_id, "-{}", operation_counter)?;
}
operation.operation_id = Some(operation_id);

operation_counter += 1;
*method_field = Some(operation);
}
Expand Down
Loading

0 comments on commit ada969a

Please sign in to comment.