Skip to main content

schema_for_yaml

Function schema_for_yaml 

Source
pub fn schema_for_yaml<T: JsonSchema>() -> Result<String>
Expand description

Generate the JSON Schema 2020-12 document for T and emit it as YAML text — ready to write to disk, share with downstream consumers, or check into version control alongside the type definition.

The output uses noyalib’s standard serializer settings; round- tripping the YAML back through crate::from_str yields an equivalent Value tree.

§Errors

As schema_for, plus YAML emission errors (likewise extremely unlikely for schema-shaped data).

§Examples

use noyalib::{schema_for_yaml, JsonSchema};

#[derive(JsonSchema)]
struct Cfg { port: u16 }

let yaml = schema_for_yaml::<Cfg>().unwrap();
assert!(yaml.contains("type: object"));