Created
April 12, 2022 13:53
-
-
Save tobz/ae49b65d55ad3a89cff528c990ef1f76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[configurable(type = "sink")] | |
pub struct BasicStruct { | |
foo: String, | |
} | |
const _: () = { | |
#[automatically_derived] | |
impl<'configurable> ::vector_config::Configurable<'configurable> for BasicStruct { | |
fn shape() -> ::vector_config::Shape { | |
::vector_config::Shape::Boolean | |
} | |
fn generate_schema( | |
schema_gen: &mut ::schemars::gen::SchemaGenerator, | |
overrides: ::vector_config::Metadata<'configurable, Self>, | |
) -> ::schemars::schema::SchemaObject { | |
let mut properties = ::indexmap::IndexMap::new(); | |
let mut required = ::std::collections::BTreeSet::new(); | |
let merged_metadata = Self::metadata().merge(overrides); | |
let foo_metadata = <String as ::vector_config::Configurable<'configurable>>::metadata() | |
.merge(merged_metadata.clone().map_default(|default| default.foo)) | |
.merge(::vector_config::Metadata::description( | |
"the endpoint to send events to", | |
)); | |
let foo_is_optional = | |
<String as ::vector_config::Configurable<'configurable>>::shape().is_optional(); | |
let mut foo_schema = | |
<String as ::vector_config::Configurable<'configurable>>::generate_schema( | |
schema_gen, | |
foo_metadata.clone(), | |
); | |
::vector_config::schema::finalize_schema(schema_gen, &mut foo_schema, foo_metadata); | |
if let Some(_) = properties.insert("foo".to_string(), foo_schema) { | |
:: core :: panicking :: panic_fmt (:: core :: fmt :: Arguments :: new_v1 (& ["schema properties already contained entry for `foo`, this should not occur"] , & [])) ; | |
} | |
if !foo_is_optional { | |
if !required.insert("foo".to_string()) { | |
:: core :: panicking :: panic_fmt (:: core :: fmt :: Arguments :: new_v1 (& ["schema properties already contained entry for `foo`, this should not occur"] , & [])) ; | |
} | |
} | |
let additional_properties = None; | |
let mut schema = ::vector_config::schema::generate_struct_schema( | |
schema_gen, | |
properties, | |
required, | |
additional_properties, | |
); | |
::vector_config::schema::finalize_schema(schema_gen, &mut schema, merged_metadata); | |
schema | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment