vespera_macro 0.3.1

Procedural macros for Vespera - automatic route discovery and OpenAPI generation
Documentation
/// Extract path parameters from a path string
pub fn extract_path_parameters(path: &str) -> Vec<String> {
    let mut params = Vec::new();

    // Iterate the split lazily — no intermediate `Vec<&str>` allocation.
    for segment in path.split('/') {
        if segment.starts_with('{') && segment.ends_with('}') {
            let param = segment.trim_start_matches('{').trim_end_matches('}');
            params.push(param.to_string());
        } else if segment.starts_with(':') {
            let param = segment.trim_start_matches(':');
            params.push(param.to_string());
        }
    }

    params
}

#[cfg(test)]
mod tests {
    use rstest::rstest;

    use super::*;

    #[rstest]
    #[case("/test", vec![])]
    #[case("/test/{id}", vec!["id"])]
    #[case("/test/{id}/test/{test_id}", vec!["id", "test_id"])]
    #[case("/test/:id/test/:test_id", vec!["id", "test_id"])]
    fn test_extract_path_parameters(#[case] path: &str, #[case] expected: Vec<&str>) {
        assert_eq!(extract_path_parameters(path), expected);
    }
}