Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions compiler-rs/clients_schema_to_openapi/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,8 @@ fn get_path_parameters(template: &str) -> Vec<&str> {
fn split_summary_desc(desc: &str) -> SplitDesc{
let segmenter = SentenceSegmenter::new();

let desc_no_newlines = desc.replace("\n\n",".\n").replace('\n'," ");

let breakpoints: Vec<usize> = segmenter
.segment_str(&desc_no_newlines)
.segment_str(&desc)
.collect();

if breakpoints.len()<2{
Expand All @@ -333,8 +331,8 @@ fn split_summary_desc(desc: &str) -> SplitDesc{
description: None
}
}
let first_line = &desc_no_newlines[breakpoints[0]..breakpoints[1]];
let rest = &desc_no_newlines[breakpoints[1]..breakpoints[breakpoints.len()-1]];
let first_line = &desc[breakpoints[0]..breakpoints[1]];
let rest = &desc[breakpoints[1]..breakpoints[breakpoints.len()-1]];

SplitDesc {
summary: Some(String::from(first_line.trim().strip_suffix('.').unwrap_or(first_line))),
Expand Down Expand Up @@ -370,20 +368,20 @@ mod tests {
summary: Some(String::from("One sentence")),
description: None
});
assert_eq!(split_summary_desc("This is\nstill one. sentence: all; together"),
assert_eq!(split_summary_desc("This is - still one. sentence: all; together"),
SplitDesc{
summary: Some(String::from("This is still one. sentence: all; together")),
summary: Some(String::from("This is - still one. sentence: all; together")),
description: None
});
assert_eq!(split_summary_desc("These are two totally. Separate sentences!"),
SplitDesc{
summary: Some(String::from("These are two totally")),
description: Some(String::from("Separate sentences!"))
});
assert_eq!(split_summary_desc("Such a weird way to separate sentences\n\nRight?"),
assert_eq!(split_summary_desc("These -> \n are allowed \n because they're needed \n\n for \n\n\n formatting"),
SplitDesc{
summary: Some(String::from("Such a weird way to separate sentences")),
description: Some(String::from("Right?"))
summary: Some(String::from("These -> \n")),
description: Some(String::from("are allowed \n because they're needed \n\n for \n\n\n formatting"))
});
assert_eq!(split_summary_desc(""),
SplitDesc{
Expand Down
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
Loading