Skip to content

Commit

Permalink
support unknown integer & number formats (#223)
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Hoß <seb@xn--ho-hia.de>
  • Loading branch information
sebhoss authored Apr 6, 2024
1 parent 83964d7 commit b320e73
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,7 @@ fn extract_number_type(value: &JSONSchemaProps) -> Result<String> {
match f.as_ref() {
"float" => "f32".to_string(),
"double" => "f64".to_string(),
x => {
bail!("unknown number {}", x);
}
_ => "f64".to_string(),
}
} else {
"f64".to_string()
Expand All @@ -520,7 +518,7 @@ fn extract_number_type(value: &JSONSchemaProps) -> Result<String> {

fn extract_integer_type(value: &JSONSchemaProps) -> Result<String> {
// Think kubernetes go types just do signed ints, but set a minimum to zero..
// rust will set uint, so emitting that when possbile
// rust will set uint, so emitting that when possible
Ok(if let Some(f) = &value.format {
match f.as_ref() {
"int8" => "i8".to_string(),
Expand All @@ -533,9 +531,7 @@ fn extract_integer_type(value: &JSONSchemaProps) -> Result<String> {
"uint32" => "u32".to_string(),
"uint64" => "u64".to_string(),
"uint128" => "u128".to_string(),
x => {
bail!("unknown integer {}", x);
}
_ => "i64".to_string(),
}
} else {
"i64".to_string()
Expand Down

0 comments on commit b320e73

Please sign in to comment.