Skip to content

Commit

Permalink
Fix argo Application generation (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
clux authored Oct 17, 2023
2 parents 4d1f2b6 + d753567 commit bde74f4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ fn resolve_additional_properties(
bail!("unknown empty dict type for {}", key)
}
}
"boolean" => Some("bool".to_string()),
"integer" => Some(extract_integer_type(s)?),
// think the type we get is the value type
x => Some(x.to_upper_camel_case()), // best guess
Expand Down Expand Up @@ -630,6 +631,30 @@ type: object
// TODO: check that anyOf: [type: integer, type: string] also works
}

#[test]
fn boolean_in_additionals() {
// as found in argo-app
init();
let schema_str = r#"
properties:
options:
additionalProperties:
type: boolean
type: object
patch:
type: string
type: object
"#;
let schema: JSONSchemaProps = serde_yaml::from_str(schema_str).unwrap();
let structs = analyze(schema, "Options").unwrap().0;
println!("got {:?}", structs);
let root = &structs[0];
assert_eq!(root.name, "Options");
assert_eq!(root.level, 0);
assert_eq!(&root.members[0].name, "options");
assert_eq!(&root.members[0].type_, "Option<BTreeMap<String, bool>>");
}

#[test]
fn enum_string() {
init();
Expand Down

0 comments on commit bde74f4

Please sign in to comment.