Skip to content

Commit

Permalink
Fix argo Application generation
Browse files Browse the repository at this point in the history
started failing on CI since they introduced a new thing in their crd.
added an extra bool cover.. didn't think people wanted a map of string -> bools
but here we are.

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux committed Oct 17, 2023
1 parent 4d1f2b6 commit d753567
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 d753567

Please sign in to comment.