#![cfg(feature = "openapi")]
use rweb::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Schema)]
#[schema(component = "GenericStruct")]
struct GenericStruct {
a: A,
b: B,
}
#[derive(Debug, Serialize, Deserialize, Schema)]
#[schema(component = "GenericStructWithConst")]
struct GenericStructWithConst {
a: A,
}
#[get("/")]
fn test_r(
_: Query>,
_: Json<
GenericStruct<
GenericStruct>,
GenericStruct>, 16>>,
>,
>,
) -> String {
String::new()
}
#[test]
fn test_generics_compile() {
let (spec, _) = openapi::spec().build(|| test_r());
let schemas = &spec.components.as_ref().unwrap().schemas;
println!("{}", serde_yaml::to_string(&schemas).unwrap());
for (name, _) in schemas {
assert!(name
.chars()
.all(|c| c.is_alphanumeric() || c == '.' || c == '_' || c == '-'))
}
}