Debian Codegraph @

src/features/utoipa.rs

raw
1 use crate::CompactString;
2
3 #[cfg_attr(docsrs, doc(cfg(feature = "utoipa")))]
4 impl utoipa::PartialSchema for CompactString {
5 fn schema() -> utoipa::openapi::RefOr<utoipa::openapi::schema::Schema> {
6 utoipa::openapi::ObjectBuilder::new()
7 .schema_type(utoipa::openapi::schema::SchemaType::new(
8 utoipa::openapi::schema::Type::String,
9 ))
10 .into()
11 }
12 }
13
14 #[cfg_attr(docsrs, doc(cfg(feature = "utoipa")))]
15 impl utoipa::ToSchema for CompactString {}
16
17 #[cfg(test)]
18 mod tests {
19 use std::string::String;
20 use utoipa::PartialSchema;
21
22 #[test]
23 fn test_compact_string_schema_matches_string() {
24 let compact_schema = <crate::CompactString as PartialSchema>::schema();
25 let string_schema = <String as PartialSchema>::schema();
26
27 assert!(compact_schema == string_schema);
28 }
29 }