Skip to content

Commit

Permalink
formatting changes to support easier excel processing
Browse files Browse the repository at this point in the history
  • Loading branch information
elerch committed Jun 23, 2017
1 parent 227813c commit f73e371
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ fn operations(service: &Value) -> Result<Vec<String>> {
Ok(rc) Ok(rc)
} }


fn parameters(service: &Value, operation: String, fn parameters(service: &Value, servicename: &String, operationname: &String,
f: &Fn(ParameterType, &str, &Value)) { f: &Fn(ParameterType, &str, &String, &String, &Value)) {
let operation = service["operations"][operation].as_object().unwrap(); let operation = service["operations"][&operationname].as_object().unwrap();
let ref shapes = service["shapes"]; let ref shapes = service["shapes"];
if operation.contains_key("input") { if operation.contains_key("input") {
let input = operation["input"]["shape"].as_str().unwrap(); let input = operation["input"]["shape"].as_str().unwrap();
f(ParameterType::Input, input, &shapes[input]); f(ParameterType::Input, input, &servicename, &operationname, &shapes[input]);
} }
// let errors = operation["errors"].as_array().unwrap(); // ignore errors for now // let errors = operation["errors"].as_array().unwrap(); // ignore errors for now
if operation.contains_key("output") { if operation.contains_key("output") {
let output = operation["output"]["shape"].as_str().unwrap(); let output = operation["output"]["shape"].as_str().unwrap();
f(ParameterType::Output, output, &shapes[output]); f(ParameterType::Output, output, &servicename, &operationname, &shapes[output]);
} }
} }


fn print_parameters(ptype: ParameterType, _: &str, parameters: &Value) { fn print_parameters(ptype: ParameterType, _: &str, service: &String, operation: &String, parameters: &Value) {
if ptype == ParameterType::Input { if ptype == ParameterType::Input {
for (key, _) in parameters["members"].as_object().unwrap() { for (key, _) in parameters["members"].as_object().unwrap() {
println!(" {}", key); println!("{}\t{}\t{}", &service, &operation, key);
} }
} }
// TODO: Determine if we want to check outputs as well // TODO: Determine if we want to check outputs as well
Expand Down Expand Up @@ -108,12 +108,9 @@ fn service_files(basepath: Option<&str>) -> Result<HashMap<String, String>> {
*/ */
fn main() { fn main() {
for (service, file) in service_files(None).unwrap() { for (service, file) in service_files(None).unwrap() {
println!("{}", service);
//println!(" {}", file);
let j: Value = json_from_path(file).unwrap(); let j: Value = json_from_path(file).unwrap();
for operation in operations(&j).unwrap() { for operation in operations(&j).unwrap() {
println!(" {}", operation); parameters(&j, &service, &operation, &print_parameters);
parameters(&j, operation, &print_parameters);
} }
} }
} }

0 comments on commit f73e371

Please sign in to comment.