diff --git a/src/specification/mod.rs b/src/specification/mod.rs index 3b904aa1..17d6b99d 100644 --- a/src/specification/mod.rs +++ b/src/specification/mod.rs @@ -1,5 +1,6 @@ use crate::specification::Structure::{Composite, Simple}; use serde::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; #[derive(Serialize, Deserialize, Debug, Clone)] @@ -47,7 +48,7 @@ pub enum CfnType { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PropertyRule { #[serde(alias = "Required")] - pub required: bool, + pub required: Option, #[serde(alias = "PrimitiveType")] pub primitive_type: Option, #[serde(alias = "PrimitiveItemType")] @@ -91,6 +92,25 @@ impl PropertyRule { } } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RawRule { + #[serde(flatten, with = "::serde_with::rust::maps_first_key_wins")] + all: HashMap, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RawSpecification { + #[serde( + alias = "PropertyTypes", + rename = "PropertyTypes", + with = "::serde_with::rust::maps_first_key_wins" + )] + pub property_types: HashMap, + + #[serde(alias = "ResourceTypes", rename = "ResourceTypes")] + pub resource_types: HashMap, +} + #[derive(Serialize, Deserialize, Debug)] pub struct Specification { #[serde( @@ -106,7 +126,9 @@ pub struct Specification { impl Specification { pub fn new() -> Specification { let str = include_str!("spec.json"); - serde_json::from_str::(str).unwrap() + let raw = serde_json::from_str::(str).unwrap(); + let compressed_str = serde_json::to_string::(&raw).unwrap(); + serde_json::from_str::(&compressed_str).unwrap() } // Resource Properties in Specification look something like: