Debian Codegraph @

src/json_schema_impls/arrayvec07.rs

raw symbols SCIP
1 use crate::SchemaGenerator;
2 use crate::_alloc_prelude::*;
3 use crate::{json_schema, JsonSchema, Schema};
4 use arrayvec07::{ArrayString, ArrayVec};
5
6 // Do not set maxLength on the schema as that describes length in characters, but we only
7 // know max length in bytes.
8 forward_impl!((<const CAP: usize> JsonSchema for ArrayString<CAP>) => String);
9
10 impl<T, const CAP: usize> JsonSchema for ArrayVec<T, CAP>
11 where
12 T: JsonSchema,
13 {
14 inline_schema!();
15
16 fn schema_name() -> alloc::borrow::Cow<'static, str> {
17 format!("Array_up_to_size_{}_of_{}", CAP, T::schema_name()).into()
18 }
19
20 fn json_schema(generator: &mut SchemaGenerator) -> Schema {
21 json_schema!({
22 "type": "array",
23 "items": generator.subschema_for::<T>(),
24 "maxItems": CAP
25 })
26 }
27 }