convert path args to camel case in format string
This commit is contained in:
		
							parent
							
								
									20a58df856
								
							
						
					
					
						commit
						12f2800b26
					
				
					 1 changed files with 27 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -392,7 +392,7 @@ fn create_method_request(
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    let mut fmt_str = path.to_string();
 | 
			
		||||
    let mut fmt_str = sanitize_path_arg(path)?;
 | 
			
		||||
    let mut fmt_args = String::new();
 | 
			
		||||
    if has_query {
 | 
			
		||||
        fmt_str.push_str("?{}");
 | 
			
		||||
| 
						 | 
				
			
			@ -408,6 +408,32 @@ fn create_method_request(
 | 
			
		|||
    Ok(out)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn sanitize_path_arg(mut path: &str) -> eyre::Result<String> {
 | 
			
		||||
    let mut out = String::new();
 | 
			
		||||
    loop {
 | 
			
		||||
        let (head, tail) = match path.split_once("{") {
 | 
			
		||||
            Some(i) => i,
 | 
			
		||||
            None => {
 | 
			
		||||
                out.push_str(path);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        path = tail;
 | 
			
		||||
        out.push_str(head);
 | 
			
		||||
        out.push('{');
 | 
			
		||||
        let (head, tail) = match path.split_once("}") {
 | 
			
		||||
            Some(i) => i,
 | 
			
		||||
            None => {
 | 
			
		||||
                eyre::bail!("unmatched bracket");
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        path = tail;
 | 
			
		||||
        out.push_str(&head.to_snake_case());
 | 
			
		||||
        out.push('}');
 | 
			
		||||
    }
 | 
			
		||||
    Ok(out)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn create_method_response(
 | 
			
		||||
    spec: &OpenApiV2,
 | 
			
		||||
    method: &str,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue