Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support unknown integer & number formats #223

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading