#![allow(dead_code)]
use rovo::schemars::JsonSchema;
#[derive(Debug, JsonSchema)]
struct BasicStruct {
name: String,
count: u32,
}
#[derive(Debug, JsonSchema)]
enum MyEnum {
A,
B(String),
}
#[derive(Debug, JsonSchema)]
#[schemars(crate = "::rovo::schemars")]
struct ExplicitCratePath {
value: i64,
}
#[derive(Debug, JsonSchema)]
struct Wrapper<T> {
inner: T,
}
#[test]
fn derive_produces_valid_json_schema() {
let schema = rovo::schemars::SchemaGenerator::default().into_root_schema_for::<BasicStruct>();
let json = serde_json::to_string(&schema).unwrap();
assert!(json.contains("BasicStruct"));
}
#[test]
fn derive_works_for_enums() {
let schema = rovo::schemars::SchemaGenerator::default().into_root_schema_for::<MyEnum>();
let json = serde_json::to_string(&schema).unwrap();
assert!(json.contains("MyEnum"));
}
#[test]
fn derive_respects_explicit_crate_path() {
let schema =
rovo::schemars::SchemaGenerator::default().into_root_schema_for::<ExplicitCratePath>();
let json = serde_json::to_string(&schema).unwrap();
assert!(json.contains("ExplicitCratePath"));
}
#[test]
fn derive_works_with_generics() {
let schema =
rovo::schemars::SchemaGenerator::default().into_root_schema_for::<Wrapper<String>>();
let json = serde_json::to_string(&schema).unwrap();
assert!(json.contains("Wrapper"));
}