Skip to content

Commit ada969a

Browse files
committed
Make operation ids URL-safe
1 parent 698be88 commit ada969a

File tree

2 files changed

+333
-322
lines changed

2 files changed

+333
-322
lines changed

openapi-converter/clients_schema_to_openapi/src/paths.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use std::collections::HashMap;
19+
use std::fmt::Write;
1920
use anyhow::{anyhow, bail};
2021
use indexmap::indexmap;
2122

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

262263
let mut operation = operation.clone();
263-
operation.operation_id = Some(format!("{}#{}", endpoint.name, operation_counter));
264+
let mut operation_id: String = endpoint.name
265+
.chars()
266+
.map(|x| match x {
267+
'_' | '.' => '-',
268+
_ => x
269+
}).collect();
270+
if operation_counter != 0 {
271+
write!(&mut operation_id, "-{}", operation_counter)?;
272+
}
273+
operation.operation_id = Some(operation_id);
274+
264275
operation_counter += 1;
265276
*method_field = Some(operation);
266277
}

0 commit comments

Comments
 (0)