|
1 | 1 | //! Deals entirely with schema analysis for the purpose of creating output structs + members
|
2 |
| -use crate::{Container, MapType, Member, Output}; |
| 2 | +use std::collections::{BTreeMap, HashMap}; |
| 3 | + |
3 | 4 | use anyhow::{bail, Result};
|
4 | 5 | use heck::ToUpperCamelCase;
|
5 | 6 | use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::{
|
6 | 7 | JSONSchemaProps, JSONSchemaPropsOrArray, JSONSchemaPropsOrBool, JSON,
|
7 | 8 | };
|
8 |
| -use std::collections::{BTreeMap, HashMap}; |
| 9 | + |
| 10 | +use crate::{Container, MapType, Member, Output}; |
9 | 11 |
|
10 | 12 | const IGNORED_KEYS: [&str; 3] = ["metadata", "apiVersion", "kind"];
|
11 | 13 |
|
@@ -429,8 +431,10 @@ fn array_recurse_for_type(
|
429 | 431 | if s.type_.is_none() && s.x_kubernetes_preserve_unknown_fields == Some(true) {
|
430 | 432 | return Ok(("Vec<serde_json::Value>".to_string(), level));
|
431 | 433 | }
|
| 434 | + |
432 | 435 | let inner_array_type = s.type_.clone().unwrap_or_default();
|
433 |
| - return match inner_array_type.as_ref() { |
| 436 | + |
| 437 | + match inner_array_type.as_ref() { |
434 | 438 | "object" => {
|
435 | 439 | // Same logic as in `extract_container` to simplify types to maps.
|
436 | 440 | let mut dict_value = None;
|
@@ -467,7 +471,7 @@ fn array_recurse_for_type(
|
467 | 471 | unknown => {
|
468 | 472 | bail!("unsupported recursive array type \"{unknown}\" for {key}")
|
469 | 473 | }
|
470 |
| - }; |
| 474 | + } |
471 | 475 | }
|
472 | 476 | // maybe fallback to serde_json::Value
|
473 | 477 | _ => bail!("only support single schema in array {}", key),
|
@@ -580,10 +584,11 @@ fn extract_integer_type(value: &JSONSchemaProps) -> Result<String> {
|
580 | 584 | // unit tests particular schema patterns
|
581 | 585 | #[cfg(test)]
|
582 | 586 | mod test {
|
583 |
| - use super::{analyze, Config as Cfg}; |
| 587 | + use std::sync::Once; |
| 588 | + |
584 | 589 | use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::JSONSchemaProps;
|
585 | 590 |
|
586 |
| - use std::sync::Once; |
| 591 | + use super::{analyze, Config as Cfg}; |
587 | 592 |
|
588 | 593 | static START: Once = Once::new();
|
589 | 594 | fn init() {
|
|
0 commit comments