serde_with/
schemars_0_8.rs

1//! Integration with [schemars v0.8](schemars_0_8).
2//!
3//! This module is only available if using the `schemars_0_8` feature of the crate.
4//!
5//! If you would like to add support for schemars to your own `serde_with` helpers
6//! see [`JsonSchemaAs`].
7
8use crate::{
9    formats::{Flexible, Format, PreferMany, PreferOne, Separator, Strict},
10    prelude::{Schema as WrapSchema, *},
11};
12use ::schemars_0_8::{
13    gen::SchemaGenerator,
14    schema::{
15        ArrayValidation, InstanceType, Metadata, NumberValidation, ObjectValidation, Schema,
16        SchemaObject, SingleOrVec, SubschemaValidation,
17    },
18    JsonSchema,
19};
20
21//===================================================================
22// Trait Definition
23
24/// A type which can be described as a JSON schema document.
25///
26/// This trait is as [`SerializeAs`] is to [`Serialize`] but for [`JsonSchema`].
27/// You can use it to make your custom [`SerializeAs`] and [`DeserializeAs`]
28/// types also support being described via JSON schemas.
29///
30/// It is used by the [`Schema`][1] type in order to implement [`JsonSchema`]
31/// for the relevant types. [`Schema`][1] is used implicitly by the [`serde_as`]
32/// macro to instruct `schemars` on how to generate JSON schemas for fields
33/// annotated with `#[serde_as(as = "...")]` attributes.
34///
35/// # Examples
36/// Suppose we have our very own `PositiveInt` type. Then we could add support
37/// for generating a schema from it like this
38///
39/// ```
40/// # extern crate schemars_0_8 as schemars;
41/// # use serde::{Serialize, Serializer, Deserialize, Deserializer};
42/// # use serde_with::{SerializeAs, DeserializeAs};
43/// use serde_with::schemars_0_8::JsonSchemaAs;
44/// use schemars::gen::SchemaGenerator;
45/// use schemars::schema::Schema;
46/// use schemars::JsonSchema;
47///
48/// # #[allow(dead_code)]
49/// struct PositiveInt;
50///
51/// impl SerializeAs<i32> for PositiveInt {
52///     // ...
53///     # fn serialize_as<S>(&value: &i32, ser: S) -> Result<S::Ok, S::Error>
54///     # where
55///     #    S: Serializer
56///     # {
57///     #    if value < 0 {
58///     #        return Err(serde::ser::Error::custom(
59///     #            "expected a positive integer value, got a negative one"
60///     #        ));
61///     #    }
62///     #
63///     #    value.serialize(ser)
64///     # }
65/// }
66///
67/// impl<'de> DeserializeAs<'de, i32> for PositiveInt {
68///     // ...
69///     # fn deserialize_as<D>(de: D) -> Result<i32, D::Error>
70///     # where
71///     #     D: Deserializer<'de>,
72///     # {
73///     #     match i32::deserialize(de) {
74///     #         Ok(value) if value < 0 => Err(serde::de::Error::custom(
75///     #             "expected a positive integer value, got a negative one"
76///     #         )),
77///     #         value => value
78///     #     }
79///     # }
80/// }
81///
82/// impl JsonSchemaAs<i32> for PositiveInt {
83///     fn schema_name() -> String {
84///         "PositiveInt".into()
85///     }
86///
87///     fn json_schema(gen: &mut SchemaGenerator) -> Schema {
88///         let mut schema = <i32 as JsonSchema>::json_schema(gen).into_object();
89///         schema.number().minimum = Some(0.0);
90///         schema.into()
91///     }
92/// }
93/// ```
94///
95/// [0]: crate::serde_as
96/// [1]: crate::Schema
97pub trait JsonSchemaAs<T: ?Sized> {
98    /// Whether JSON Schemas generated for this type should be re-used where possible using the `$ref` keyword.
99    ///
100    /// For trivial types (such as primitives), this should return `false`. For more complex types, it should return `true`.
101    /// For recursive types, this **must** return `true` to prevent infinite cycles when generating schemas.
102    ///
103    /// By default, this returns `true`.
104    fn is_referenceable() -> bool {
105        true
106    }
107
108    /// The name of the generated JSON Schema.
109    ///
110    /// This is used as the title for root schemas, and the key within the root's `definitions` property for sub-schemas.
111    ///
112    /// As the schema name is used as as part of `$ref` it has to be a valid URI path segment according to
113    /// [RFC 3986 Section-3](https://datatracker.ietf.org/doc/html/rfc3986#section-3).
114    fn schema_name() -> String;
115
116    /// Returns a string that uniquely identifies the schema produced by this type.
117    ///
118    /// This does not have to be a human-readable string, and the value will not itself be included in generated schemas.
119    /// If two types produce different schemas, then they **must** have different `schema_id()`s,
120    /// but two types that produce identical schemas should *ideally* have the same `schema_id()`.
121    ///
122    /// The default implementation returns the same value as `schema_name()`.
123    fn schema_id() -> Cow<'static, str> {
124        Cow::Owned(Self::schema_name())
125    }
126
127    /// Generates a JSON Schema for this type.
128    ///
129    /// If the returned schema depends on any [referenceable](JsonSchema::is_referenceable) schemas, then this method will
130    /// add them to the [`SchemaGenerator`]'s schema definitions.
131    ///
132    /// This should not return a `$ref` schema.
133    fn json_schema(gen: &mut SchemaGenerator) -> Schema;
134}
135
136impl<T, TA> JsonSchema for WrapSchema<T, TA>
137where
138    T: ?Sized,
139    TA: JsonSchemaAs<T>,
140{
141    fn schema_name() -> String {
142        TA::schema_name()
143    }
144
145    fn schema_id() -> Cow<'static, str> {
146        TA::schema_id()
147    }
148
149    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
150        TA::json_schema(gen)
151    }
152
153    fn is_referenceable() -> bool {
154        TA::is_referenceable()
155    }
156}
157
158//===================================================================
159// Macro helpers
160
161macro_rules! forward_schema {
162    ($fwd:ty) => {
163        fn schema_name() -> String {
164            <$fwd as JsonSchema>::schema_name()
165        }
166
167        fn schema_id() -> Cow<'static, str> {
168            <$fwd as JsonSchema>::schema_id()
169        }
170
171        fn json_schema(gen: &mut SchemaGenerator) -> Schema {
172            <$fwd as JsonSchema>::json_schema(gen)
173        }
174
175        fn is_referenceable() -> bool {
176            <$fwd as JsonSchema>::is_referenceable()
177        }
178    };
179}
180
181//===================================================================
182// Common definitions for various std types
183
184impl<'a, T: 'a, TA: 'a> JsonSchemaAs<&'a T> for &'a TA
185where
186    T: ?Sized,
187    TA: JsonSchemaAs<T>,
188{
189    <&'a WrapSchema<T, TA> as JsonSchema>::schema_name();
<&'a WrapSchema<T, TA> as JsonSchema>::schema_id();
gen
<&'a WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
<&'a WrapSchema<T, TA> as JsonSchema>::is_referenceable();forward_schema!(&'a WrapSchema<T, TA>);
190}
191
192impl<'a, T: 'a, TA: 'a> JsonSchemaAs<&'a mut T> for &'a mut TA
193where
194    T: ?Sized,
195    TA: JsonSchemaAs<T>,
196{
197    <&'a mut WrapSchema<T, TA> as JsonSchema>::schema_name();
<&'a mut WrapSchema<T, TA> as JsonSchema>::schema_id();
gen
<&'a mut WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
<&'a mut WrapSchema<T, TA> as JsonSchema>::is_referenceable();forward_schema!(&'a mut WrapSchema<T, TA>);
198}
199
200impl<T, TA> JsonSchemaAs<Option<T>> for Option<TA>
201where
202    TA: JsonSchemaAs<T>,
203{
204    <Option<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Option<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Option<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Option<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Option<WrapSchema<T, TA>>);
205}
206
207impl<T, TA> JsonSchemaAs<Box<T>> for Box<TA>
208where
209    T: ?Sized,
210    TA: JsonSchemaAs<T>,
211{
212    <Box<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Box<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Box<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Box<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Box<WrapSchema<T, TA>>);
213}
214
215impl<T, TA> JsonSchemaAs<Rc<T>> for Rc<TA>
216where
217    T: ?Sized,
218    TA: JsonSchemaAs<T>,
219{
220    <Rc<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Rc<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Rc<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Rc<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Rc<WrapSchema<T, TA>>);
221}
222
223impl<T, TA> JsonSchemaAs<Arc<T>> for Arc<TA>
224where
225    T: ?Sized,
226    TA: JsonSchemaAs<T>,
227{
228    <Arc<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Arc<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Arc<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Arc<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Arc<WrapSchema<T, TA>>);
229}
230
231impl<T, TA> JsonSchemaAs<Vec<T>> for Vec<TA>
232where
233    TA: JsonSchemaAs<T>,
234{
235    <Vec<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Vec<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Vec<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Vec<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Vec<WrapSchema<T, TA>>);
236}
237
238impl<T, TA> JsonSchemaAs<VecDeque<T>> for VecDeque<TA>
239where
240    TA: JsonSchemaAs<T>,
241{
242    <VecDeque<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(VecDeque<WrapSchema<T, TA>>);
243}
244
245// schemars only requires that V implement JsonSchema for BTreeMap<K, V>
246impl<K, V, KA, VA> JsonSchemaAs<BTreeMap<K, V>> for BTreeMap<KA, VA>
247where
248    VA: JsonSchemaAs<V>,
249{
250    <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as JsonSchema>::schema_name();
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as JsonSchema>::schema_id();
gen
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
        JsonSchema>::json_schema(gen);
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
        JsonSchema>::is_referenceable();forward_schema!(BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>>);
251}
252
253// schemars only requires that V implement JsonSchema for HashMap<K, V>
254impl<K, V, S, KA, VA> JsonSchemaAs<HashMap<K, V, S>> for HashMap<KA, VA, S>
255where
256    VA: JsonSchemaAs<V>,
257{
258    <HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as
        JsonSchema>::schema_name();
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as JsonSchema>::schema_id();
gen
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as
        JsonSchema>::json_schema(gen);
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as
        JsonSchema>::is_referenceable();forward_schema!(HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S>);
259}
260
261impl<T, TA> JsonSchemaAs<BTreeSet<T>> for BTreeSet<TA>
262where
263    TA: JsonSchemaAs<T>,
264{
265    <BTreeSet<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(BTreeSet<WrapSchema<T, TA>>);
266}
267
268impl<T, TA, S> JsonSchemaAs<T> for HashSet<TA, S>
269where
270    TA: JsonSchemaAs<T>,
271{
272    <HashSet<WrapSchema<T, TA>, S> as JsonSchema>::schema_name();
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::schema_id();
gen
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::json_schema(gen);
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::is_referenceable();forward_schema!(HashSet<WrapSchema<T, TA>, S>);
273}
274
275impl<T, TA> JsonSchemaAs<Bound<T>> for Bound<TA>
276where
277    TA: JsonSchemaAs<T>,
278{
279    <Bound<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Bound<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Bound<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Bound<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Bound<WrapSchema<T, TA>>);
280}
281
282impl<T, TA> JsonSchemaAs<Range<T>> for Range<TA>
283where
284    TA: JsonSchemaAs<T>,
285{
286    <Range<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Range<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Range<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Range<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Range<WrapSchema<T, TA>>);
287}
288
289// Note: Not included in `schemars`
290// impl<T, TA> JsonSchemaAs<RangeFrom<T>> for RangeFrom<TA>
291// where
292//     TA: JsonSchemaAs<T>,
293// {
294//     forward_schema!(RangeFrom<WrapSchema<T, TA>>);
295// }
296
297// impl<T, TA> JsonSchemaAs<RangeTo<T>> for RangeTo<TA>
298// where
299//     TA: JsonSchemaAs<T>,
300// {
301//     forward_schema!(RangeTo<WrapSchema<T, TA>>);
302// }
303
304impl<T, TA> JsonSchemaAs<RangeInclusive<T>> for RangeInclusive<TA>
305where
306    TA: JsonSchemaAs<T>,
307{
308    <RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(RangeInclusive<WrapSchema<T, TA>>);
309}
310
311impl<T, TA, const N: usize> JsonSchemaAs<[T; N]> for [TA; N]
312where
313    TA: JsonSchemaAs<T>,
314{
315    fn schema_name() -> String {
316        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("[{0}; {1}]",
                <WrapSchema<T, TA>>::schema_name(), N))
    })std::format!("[{}; {}]", <WrapSchema<T, TA>>::schema_name(), N)
317    }
318
319    fn schema_id() -> Cow<'static, str> {
320        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("[{0}; {1}]",
                <WrapSchema<T, TA>>::schema_id(), N))
    })std::format!("[{}; {}]", <WrapSchema<T, TA>>::schema_id(), N).into()
321    }
322
323    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
324        let (max, min) = match N.try_into() {
325            Ok(len) => (Some(len), Some(len)),
326            Err(_) => (None, Some(u32::MAX)),
327        };
328
329        SchemaObject {
330            instance_type: Some(InstanceType::Array.into()),
331            array: Some(Box::new(ArrayValidation {
332                items: Some(gen.subschema_for::<WrapSchema<T, TA>>().into()),
333                max_items: max,
334                min_items: min,
335                ..Default::default()
336            })),
337            ..Default::default()
338        }
339        .into()
340    }
341
342    fn is_referenceable() -> bool {
343        false
344    }
345}
346
347macro_rules! schema_for_tuple {
348    (
349        ( $( $ts:ident )+ )
350        ( $( $as:ident )+ )
351    ) => {
352        impl<$($ts,)+ $($as,)+> JsonSchemaAs<($($ts,)+)> for ($($as,)+)
353        where
354            $( $as: JsonSchemaAs<$ts>, )+
355        {
356            forward_schema!(( $( WrapSchema<$ts, $as>, )+ ));
357        }
358    }
359}
360
361impl JsonSchemaAs<()> for () {
362    <() as JsonSchema>::schema_name();
<() as JsonSchema>::schema_id();
gen
<() as JsonSchema>::json_schema(gen);
<() as JsonSchema>::is_referenceable();forward_schema!(());
363}
364
365// schemars only implements JsonSchema for tuples up to 15 elements so we do
366// the same here.
367impl<T0, A0> JsonSchemaAs<(T0,)> for (A0,) where A0: JsonSchemaAs<T0> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>,) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>,) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>,) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>,) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0)(A0));
368impl<T0, T1, A0, A1> JsonSchemaAs<(T0, T1)> for (A0, A1) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1) (A0 A1));
369impl<T0, T1, T2, A0, A1, A2> JsonSchemaAs<(T0, T1, T2)> for (A0, A1, A2) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2) (A0 A1 A2));
370impl<T0, T1, T2, T3, A0, A1, A2, A3> JsonSchemaAs<(T0, T1, T2, T3)> for
    (A0, A1, A2, A3) where A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>,
    A2: JsonSchemaAs<T2>, A3: JsonSchemaAs<T3> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3) (A0 A1 A2 A3));
371impl<T0, T1, T2, T3, T4, A0, A1, A2, A3, A4>
    JsonSchemaAs<(T0, T1, T2, T3, T4)> for (A0, A1, A2, A3, A4) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4) (A0 A1 A2 A3 A4));
372impl<T0, T1, T2, T3, T4, T5, A0, A1, A2, A3, A4, A5>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5)> for (A0, A1, A2, A3, A4, A5) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5) (A0 A1 A2 A3 A4 A5));
373impl<T0, T1, T2, T3, T4, T5, T6, A0, A1, A2, A3, A4, A5, A6>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6)> for
    (A0, A1, A2, A3, A4, A5, A6) where A0: JsonSchemaAs<T0>,
    A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>, A3: JsonSchemaAs<T3>,
    A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>, A6: JsonSchemaAs<T6> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6) (A0 A1 A2 A3 A4 A5 A6));
374impl<T0, T1, T2, T3, T4, T5, T6, T7, A0, A1, A2, A3, A4, A5, A6, A7>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7)> for
    (A0, A1, A2, A3, A4, A5, A6, A7) where A0: JsonSchemaAs<T0>,
    A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>, A3: JsonSchemaAs<T3>,
    A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>, A6: JsonSchemaAs<T6>,
    A7: JsonSchemaAs<T7> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7) (A0 A1 A2 A3 A4 A5 A6 A7));
375impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, A0, A1, A2, A3, A4, A5, A6, A7, A8>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8) where A0: JsonSchemaAs<T0>,
    A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>, A3: JsonSchemaAs<T3>,
    A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>, A6: JsonSchemaAs<T6>,
    A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7 T8) (A0 A1 A2 A3 A4 A5 A6 A7 A8));
376impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, A0, A1, A2, A3, A4, A5, A6, A7,
    A8, A9> JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) where A0: JsonSchemaAs<T0>,
    A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>, A3: JsonSchemaAs<T3>,
    A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>, A6: JsonSchemaAs<T6>,
    A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>, A9: JsonSchemaAs<T9> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7 T8 T9) (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9));
377impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, A0, A1, A2, A3, A4, A5, A6,
    A7, A8, A9, A10>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) where A0: JsonSchemaAs<T0>,
    A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>, A3: JsonSchemaAs<T3>,
    A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>, A6: JsonSchemaAs<T6>,
    A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>, A9: JsonSchemaAs<T9>,
    A10: JsonSchemaAs<T10> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10) (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10));
378impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, A0, A1, A2, A3, A4, A5,
    A6, A7, A8, A9, A10, A11>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>,
    A6: JsonSchemaAs<T6>, A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>,
    A9: JsonSchemaAs<T9>, A10: JsonSchemaAs<T10>, A11: JsonSchemaAs<T11> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11) (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11));
379impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, A0, A1, A2, A3,
    A4, A5, A6, A7, A8, A9, A10, A11, A12>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>,
    A6: JsonSchemaAs<T6>, A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>,
    A9: JsonSchemaAs<T9>, A10: JsonSchemaAs<T10>, A11: JsonSchemaAs<T11>,
    A12: JsonSchemaAs<T12> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!(
380    (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12)
381    (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12)
382);
383impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, A0, A1, A2,
    A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>
    for (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>,
    A6: JsonSchemaAs<T6>, A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>,
    A9: JsonSchemaAs<T9>, A10: JsonSchemaAs<T10>, A11: JsonSchemaAs<T11>,
    A12: JsonSchemaAs<T12>, A13: JsonSchemaAs<T13> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!(
384    (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13)
385    (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13)
386);
387impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, A0, A1,
    A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
    T14)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) where
    A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>,
    A6: JsonSchemaAs<T6>, A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>,
    A9: JsonSchemaAs<T9>, A10: JsonSchemaAs<T10>, A11: JsonSchemaAs<T11>,
    A12: JsonSchemaAs<T12>, A13: JsonSchemaAs<T13>, A14: JsonSchemaAs<T14> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>) as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>) as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>) as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>) as
                JsonSchema>::is_referenceable()
    }
}schema_for_tuple!(
388    (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14)
389    (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14)
390);
391impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, A0,
    A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>
    JsonSchemaAs<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
    T14, T15)> for
    (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)
    where A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1>, A2: JsonSchemaAs<T2>,
    A3: JsonSchemaAs<T3>, A4: JsonSchemaAs<T4>, A5: JsonSchemaAs<T5>,
    A6: JsonSchemaAs<T6>, A7: JsonSchemaAs<T7>, A8: JsonSchemaAs<T8>,
    A9: JsonSchemaAs<T9>, A10: JsonSchemaAs<T10>, A11: JsonSchemaAs<T11>,
    A12: JsonSchemaAs<T12>, A13: JsonSchemaAs<T13>, A14: JsonSchemaAs<T14>,
    A15: JsonSchemaAs<T15> {
    fn schema_name() -> String {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>,
                WrapSchema<T15, A15>) as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>,
                WrapSchema<T15, A15>) as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>,
                WrapSchema<T15, A15>) as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
                WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
                WrapSchema<T6, A6>, WrapSchema<T7, A7>, WrapSchema<T8, A8>,
                WrapSchema<T9, A9>, WrapSchema<T10, A10>,
                WrapSchema<T11, A11>, WrapSchema<T12, A12>,
                WrapSchema<T13, A13>, WrapSchema<T14, A14>,
                WrapSchema<T15, A15>) as JsonSchema>::is_referenceable()
    }
}schema_for_tuple!(
392    (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14 T15)
393    (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15)
394);
395
396//===================================================================
397// Impls for serde_with types.
398
399impl<T: JsonSchema> JsonSchemaAs<T> for Same {
400    <T as JsonSchema>::schema_name();
<T as JsonSchema>::schema_id();
gen
<T as JsonSchema>::json_schema(gen);
<T as JsonSchema>::is_referenceable();forward_schema!(T);
401}
402
403impl<T> JsonSchemaAs<T> for DisplayFromStr {
404    <String as JsonSchema>::schema_name();
<String as JsonSchema>::schema_id();
gen
<String as JsonSchema>::json_schema(gen);
<String as JsonSchema>::is_referenceable();forward_schema!(String);
405}
406
407#[cfg(feature = "hex")]
408impl<T, F: formats::Format> JsonSchemaAs<T> for hex::Hex<F> {
409    fn schema_name() -> String {
410        "Hex<F>".into()
411    }
412
413    fn schema_id() -> Cow<'static, str> {
414        "serde_with::hex::Hex<F>".into()
415    }
416
417    fn json_schema(_: &mut SchemaGenerator) -> Schema {
418        use ::schemars_0_8::schema::StringValidation;
419
420        SchemaObject {
421            instance_type: Some(InstanceType::String.into()),
422            string: Some(Box::new(StringValidation {
423                pattern: Some(r"^(?:[0-9A-Fa-f]{2})*$".to_owned()),
424                ..Default::default()
425            })),
426            ..Default::default()
427        }
428        .into()
429    }
430
431    fn is_referenceable() -> bool {
432        false
433    }
434}
435
436impl JsonSchemaAs<bool> for BoolFromInt<Strict> {
437    fn schema_name() -> String {
438        "BoolFromInt<Strict>".into()
439    }
440
441    fn schema_id() -> Cow<'static, str> {
442        "serde_with::BoolFromInt<Strict>".into()
443    }
444
445    fn json_schema(_: &mut SchemaGenerator) -> Schema {
446        SchemaObject {
447            instance_type: Some(InstanceType::Integer.into()),
448            number: Some(Box::new(NumberValidation {
449                minimum: Some(0.0),
450                maximum: Some(1.0),
451                ..Default::default()
452            })),
453            ..Default::default()
454        }
455        .into()
456    }
457
458    fn is_referenceable() -> bool {
459        false
460    }
461}
462
463impl JsonSchemaAs<bool> for BoolFromInt<Flexible> {
464    fn schema_name() -> String {
465        "BoolFromInt<Flexible>".into()
466    }
467
468    fn schema_id() -> Cow<'static, str> {
469        "serde_with::BoolFromInt<Flexible>".into()
470    }
471
472    fn json_schema(_: &mut SchemaGenerator) -> Schema {
473        SchemaObject {
474            instance_type: Some(InstanceType::Integer.into()),
475            ..Default::default()
476        }
477        .into()
478    }
479
480    fn is_referenceable() -> bool {
481        false
482    }
483}
484
485impl<'a, T: 'a> JsonSchemaAs<Cow<'a, T>> for BorrowCow
486where
487    T: ?Sized + ToOwned,
488    Cow<'a, T>: JsonSchema,
489{
490    <Cow<'a, T> as JsonSchema>::schema_name();
<Cow<'a, T> as JsonSchema>::schema_id();
gen
<Cow<'a, T> as JsonSchema>::json_schema(gen);
<Cow<'a, T> as JsonSchema>::is_referenceable();forward_schema!(Cow<'a, T>);
491}
492
493impl<T> JsonSchemaAs<T> for Bytes {
494    <Vec<u8> as JsonSchema>::schema_name();
<Vec<u8> as JsonSchema>::schema_id();
gen
<Vec<u8> as JsonSchema>::json_schema(gen);
<Vec<u8> as JsonSchema>::is_referenceable();forward_schema!(Vec<u8>);
495}
496
497impl JsonSchemaAs<Vec<u8>> for BytesOrString {
498    fn schema_name() -> String {
499        "BytesOrString".into()
500    }
501
502    fn schema_id() -> Cow<'static, str> {
503        "serde_with::BytesOrString".into()
504    }
505
506    fn json_schema(generator: &mut SchemaGenerator) -> Schema {
507        SchemaObject {
508            subschemas: Some(Box::new(SubschemaValidation {
509                any_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([generator.subschema_for::<Vec<u8>>(),
                SchemaObject {
                        instance_type: Some(InstanceType::String.into()),
                        metadata: Some(Box::new(Metadata {
                                    write_only: true,
                                    ..Default::default()
                                })),
                        ..Default::default()
                    }.into()]))std::vec![
510                    generator.subschema_for::<Vec<u8>>(),
511                    SchemaObject {
512                        instance_type: Some(InstanceType::String.into()),
513                        metadata: Some(Box::new(Metadata {
514                            write_only: true,
515                            ..Default::default()
516                        })),
517                        ..Default::default()
518                    }
519                    .into()
520                ]),
521                ..Default::default()
522            })),
523            ..Default::default()
524        }
525        .into()
526    }
527
528    fn is_referenceable() -> bool {
529        false
530    }
531}
532
533impl<T, TA> JsonSchemaAs<T> for DefaultOnError<TA>
534where
535    TA: JsonSchemaAs<T>,
536{
537    <WrapSchema<T, TA> as JsonSchema>::schema_name();
<WrapSchema<T, TA> as JsonSchema>::schema_id();
gen
<WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
<WrapSchema<T, TA> as JsonSchema>::is_referenceable();forward_schema!(WrapSchema<T, TA>);
538}
539
540impl<T, TA> JsonSchemaAs<T> for DefaultOnNull<TA>
541where
542    TA: JsonSchemaAs<T>,
543{
544    <Option<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Option<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Option<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Option<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Option<WrapSchema<T, TA>>);
545}
546
547impl<O, T: JsonSchema> JsonSchemaAs<O> for FromInto<T> {
548    <T as JsonSchema>::schema_name();
<T as JsonSchema>::schema_id();
gen
<T as JsonSchema>::json_schema(gen);
<T as JsonSchema>::is_referenceable();forward_schema!(T);
549}
550
551impl<O, T: JsonSchema> JsonSchemaAs<O> for FromIntoRef<T> {
552    <T as JsonSchema>::schema_name();
<T as JsonSchema>::schema_id();
gen
<T as JsonSchema>::json_schema(gen);
<T as JsonSchema>::is_referenceable();forward_schema!(T);
553}
554
555impl<T, U: JsonSchema> JsonSchemaAs<T> for TryFromInto<U> {
556    <U as JsonSchema>::schema_name();
<U as JsonSchema>::schema_id();
gen
<U as JsonSchema>::json_schema(gen);
<U as JsonSchema>::is_referenceable();forward_schema!(U);
557}
558
559impl<T, U: JsonSchema> JsonSchemaAs<T> for TryFromIntoRef<U> {
560    <U as JsonSchema>::schema_name();
<U as JsonSchema>::schema_id();
gen
<U as JsonSchema>::json_schema(gen);
<U as JsonSchema>::is_referenceable();forward_schema!(U);
561}
562
563impl<T, TA, FA> JsonSchemaAs<T> for IfIsHumanReadable<TA, FA>
564where
565    TA: JsonSchemaAs<T>,
566{
567    // serde_json always has `is_human_readable` set to true so we just use the
568    // schema for the human readable variant.
569    <WrapSchema<T, TA> as JsonSchema>::schema_name();
<WrapSchema<T, TA> as JsonSchema>::schema_id();
gen
<WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
<WrapSchema<T, TA> as JsonSchema>::is_referenceable();forward_schema!(WrapSchema<T, TA>);
570}
571
572macro_rules! schema_for_map {
573    ($type:ty) => {
574        impl<K, V, KA, VA> JsonSchemaAs<$type> for Map<KA, VA>
575        where
576            VA: JsonSchemaAs<V>,
577        {
578            forward_schema!(WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>>);
579        }
580    };
581}
582
583impl<K, V, KA, VA> JsonSchemaAs<[(K, V)]> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!([(K, V)]);
584impl<K, V, KA, VA> JsonSchemaAs<BTreeSet<(K, V)>> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!(BTreeSet<(K, V)>);
585impl<K, V, KA, VA> JsonSchemaAs<BinaryHeap<(K, V)>> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!(BinaryHeap<(K, V)>);
586impl<K, V, KA, VA> JsonSchemaAs<Box<[(K, V)]>> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!(Box<[(K, V)]>);
587impl<K, V, KA, VA> JsonSchemaAs<LinkedList<(K, V)>> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!(LinkedList<(K, V)>);
588impl<K, V, KA, VA> JsonSchemaAs<Vec<(K, V)>> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!(Vec<(K, V)>);
589impl<K, V, KA, VA> JsonSchemaAs<VecDeque<(K, V)>> for Map<KA, VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
                JsonSchema>::is_referenceable()
    }
}schema_for_map!(VecDeque<(K, V)>);
590
591impl<K, V, S, KA, VA> JsonSchemaAs<HashSet<(K, V), S>> for Map<KA, VA>
592where
593    VA: JsonSchemaAs<V>,
594{
595    <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_name();
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_id();
gen
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
        JsonSchema>::json_schema(gen);
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
        JsonSchema>::is_referenceable();forward_schema!(WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>>);
596}
597
598impl<T> JsonSchemaAs<Vec<T>> for EnumMap
599where
600    T: JsonSchema,
601{
602    fn schema_name() -> String {
603        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("EnumMap({0})", T::schema_name()))
    })std::format!("EnumMap({})", T::schema_name())
604    }
605
606    fn schema_id() -> Cow<'static, str> {
607        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("serde_with::EnumMap({0})",
                T::schema_id()))
    })std::format!("serde_with::EnumMap({})", T::schema_id()).into()
608    }
609
610    // We generate the schema here by going through all the variants of the
611    // enum (the oneOf property) and sticking all their properties onto an
612    // object.
613    //
614    // This will be wrong if the object is not an externally tagged enum but in
615    // that case serialization and deserialization will fail so it is probably
616    // OK.
617    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
618        let mut object = SchemaObject {
619            instance_type: Some(InstanceType::Object.into()),
620            ..Default::default()
621        };
622        let inner = T::json_schema(gen).into_object();
623
624        let one_of = match inner.subschemas {
625            Some(subschemas) => match subschemas.one_of {
626                Some(one_of) => one_of,
627                None => return object.into(),
628            },
629            None => return object.into(),
630        };
631
632        let properties = &mut object.object().properties;
633        for schema in one_of {
634            if let Some(object) = schema.into_object().object {
635                properties.extend(object.properties.into_iter());
636            }
637        }
638
639        object.object().additional_properties = Some(Box::new(Schema::Bool(false)));
640        object.into()
641    }
642
643    fn is_referenceable() -> bool {
644        true
645    }
646}
647
648impl<T, TA> WrapSchema<Vec<T>, KeyValueMap<TA>>
649where
650    TA: JsonSchemaAs<T>,
651{
652    /// Transform a schema from the entry type of a `KeyValueMap<T>` to the
653    /// resulting field type.
654    ///
655    /// This usually means doing one of two things:
656    /// 1. removing the `$key$` property from an object, or,
657    /// 2. removing the first item from an array.
658    ///
659    /// We also need to adjust any fields that control the number of items or
660    /// properties allowed such as `(max|min)_properties` or `(max|min)_items`.
661    ///
662    /// This is mostly straightforward. Where things get hairy is when dealing
663    /// with subschemas. JSON schemas allow you to build the schema for an
664    /// object by combining multiple subschemas:
665    /// - You can match exactly one of a set of subschemas (`one_of`).
666    /// - You can match any of a set of subschemas (`any_of`).
667    /// - You can match all of a set of subschemas (`all_of`).
668    ///
669    /// Unfortunately for us, we need to handle all of these options by recursing
670    /// into the subschemas and applying the same transformations as above.
671    fn kvmap_transform_schema_0_8(gen: &mut SchemaGenerator, schema: &mut Schema) {
672        let mut parents = Vec::new();
673
674        Self::kvmap_transform_schema_impl_0_8(gen, schema, &mut parents, 0);
675    }
676
677    fn kvmap_transform_schema_impl_0_8(
678        gen: &mut SchemaGenerator,
679        schema: &mut Schema,
680        parents: &mut Vec<String>,
681        depth: u32,
682    ) {
683        if depth > 8 {
684            return;
685        }
686
687        let mut done = false;
688        let schema = match schema {
689            Schema::Object(schema) => schema,
690            _ => return,
691        };
692
693        // The schema is a reference to a schema defined elsewhere.
694        //
695        // If possible we replace it with its definition but if that is not
696        // available then we give up and leave it as-is.
697        let mut parents = if let Some(reference) = &schema.reference {
698            let name = match reference.strip_prefix(&gen.settings().definitions_path) {
699                Some(name) => name,
700                // Reference is defined elsewhere, nothing we can do.
701                None => return,
702            };
703
704            // We are in a recursive reference loop. No point in continuing.
705            if parents.iter().any(|parent| parent == name) {
706                return;
707            }
708
709            let name = name.to_owned();
710            *schema = match gen.definitions().get(&name) {
711                Some(Schema::Object(schema)) => schema.clone(),
712                _ => return,
713            };
714
715            parents.push(name);
716            utils::DropGuard::new(parents, |parents| drop(parents.pop()))
717        } else {
718            utils::DropGuard::unguarded(parents)
719        };
720
721        if let Some(object) = &mut schema.object {
722            // For objects KeyValueMap uses the $key$ property so we need to remove it from
723            // the inner schema.
724
725            done |= object.properties.remove("$key$").is_some();
726            done |= object.required.remove("$key$");
727
728            if let Some(max) = &mut object.max_properties {
729                *max = max.saturating_sub(1);
730            }
731
732            if let Some(min) = &mut object.min_properties {
733                *min = min.saturating_sub(1);
734            }
735        }
736
737        if let Some(array) = &mut schema.array {
738            // For arrays KeyValueMap uses the first array element so we need to remove it
739            // from the inner schema.
740
741            if let Some(SingleOrVec::Vec(items)) = &mut array.items {
742                // If the array is empty then the leading element may be following the
743                // additionalItem schema. In that case we do nothing.
744                if !items.is_empty() {
745                    items.remove(0);
746                    done = true;
747                }
748            }
749
750            if let Some(max) = &mut array.max_items {
751                *max = max.saturating_sub(1);
752            }
753
754            if let Some(min) = &mut array.min_items {
755                *min = min.saturating_sub(1);
756            }
757        }
758
759        // We've already modified the schema so there's no need to do more work.
760        if done {
761            return;
762        }
763
764        let subschemas = match &mut schema.subschemas {
765            Some(subschemas) => subschemas,
766            None => return,
767        };
768
769        if let Some(one_of) = &mut subschemas.one_of {
770            for subschema in one_of {
771                Self::kvmap_transform_schema_impl_0_8(gen, subschema, &mut parents, depth + 1);
772            }
773        }
774
775        if let Some(any_of) = &mut subschemas.any_of {
776            for subschema in any_of {
777                Self::kvmap_transform_schema_impl_0_8(gen, subschema, &mut parents, depth + 1);
778            }
779        }
780
781        if let Some(all_of) = &mut subschemas.all_of {
782            for subschema in all_of {
783                Self::kvmap_transform_schema_impl_0_8(gen, subschema, &mut parents, depth + 1);
784            }
785        }
786    }
787}
788
789impl<T, TA> JsonSchemaAs<Vec<T>> for KeyValueMap<TA>
790where
791    TA: JsonSchemaAs<T>,
792{
793    fn schema_name() -> String {
794        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("KeyValueMap({0})",
                <WrapSchema<T, TA>>::schema_name()))
    })std::format!("KeyValueMap({})", <WrapSchema<T, TA>>::schema_name())
795    }
796
797    fn schema_id() -> Cow<'static, str> {
798        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("serde_with::KeyValueMap({0})",
                <WrapSchema<T, TA>>::schema_id()))
    })std::format!(
799            "serde_with::KeyValueMap({})",
800            <WrapSchema<T, TA>>::schema_id()
801        )
802        .into()
803    }
804
805    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
806        let mut value = <WrapSchema<T, TA>>::json_schema(gen);
807        <WrapSchema<Vec<T>, KeyValueMap<TA>>>::kvmap_transform_schema_0_8(gen, &mut value);
808
809        SchemaObject {
810            instance_type: Some(InstanceType::Object.into()),
811            object: Some(Box::new(ObjectValidation {
812                additional_properties: Some(Box::new(value)),
813                ..Default::default()
814            })),
815            ..Default::default()
816        }
817        .into()
818    }
819
820    fn is_referenceable() -> bool {
821        true
822    }
823}
824
825impl<K, V, KA, VA, const N: usize> JsonSchemaAs<[(K, V); N]> for Map<KA, VA>
826where
827    VA: JsonSchemaAs<V>,
828{
829    <WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_name();
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_id();
gen
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
        JsonSchema>::json_schema(gen);
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
        JsonSchema>::is_referenceable();forward_schema!(WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>>);
830}
831
832macro_rules! map_first_last_wins_schema {
833    ($(=> $extra:ident)? $type:ty) => {
834        impl<K, V, $($extra,)? KA, VA> JsonSchemaAs<$type> for MapFirstKeyWins<KA, VA>
835        where
836            VA: JsonSchemaAs<V>,
837        {
838            forward_schema!(BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>>);
839        }
840
841        impl<K, V, $($extra,)? KA, VA> JsonSchemaAs<$type> for MapPreventDuplicates<KA, VA>
842        where
843            VA: JsonSchemaAs<V>,
844        {
845            forward_schema!(BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>>);
846        }
847    }
848}
849
850impl<K, V, KA, VA> JsonSchemaAs<BTreeMap<K, V>> for MapFirstKeyWins<KA, VA>
    where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, KA, VA> JsonSchemaAs<BTreeMap<K, V>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(BTreeMap<K, V>);
851impl<K, V, S, KA, VA> JsonSchemaAs<HashMap<K, V, S>> for
    MapFirstKeyWins<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, S, KA, VA> JsonSchemaAs<HashMap<K, V, S>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S HashMap<K, V, S>);
852#[cfg(feature = "hashbrown_0_14")]
853impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_14::HashMap<K, V, S>> for
    MapFirstKeyWins<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_14::HashMap<K, V, S>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S hashbrown_0_14::HashMap<K, V, S>);
854#[cfg(feature = "hashbrown_0_15")]
855impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_15::HashMap<K, V, S>> for
    MapFirstKeyWins<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_15::HashMap<K, V, S>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S hashbrown_0_15::HashMap<K, V, S>);
856#[cfg(feature = "hashbrown_0_16")]
857impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_16::HashMap<K, V, S>> for
    MapFirstKeyWins<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_16::HashMap<K, V, S>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S hashbrown_0_16::HashMap<K, V, S>);
858#[cfg(feature = "indexmap_1")]
859impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_1::IndexMap<K, V, S>> for
    MapFirstKeyWins<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_1::IndexMap<K, V, S>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S indexmap_1::IndexMap<K, V, S>);
860#[cfg(feature = "indexmap_2")]
861impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_2::IndexMap<K, V, S>> for
    MapFirstKeyWins<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}
impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_2::IndexMap<K, V, S>> for
    MapPreventDuplicates<KA, VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
                JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S indexmap_2::IndexMap<K, V, S>);
862
863impl<T, TA> JsonSchemaAs<Vec<T>> for OneOrMany<TA, PreferOne>
864where
865    TA: JsonSchemaAs<T>,
866{
867    fn schema_name() -> String {
868        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("OneOrMany({0},PreferOne)",
                <WrapSchema<T, TA>>::schema_name()))
    })std::format!(
869            "OneOrMany({},PreferOne)",
870            <WrapSchema<T, TA>>::schema_name()
871        )
872    }
873
874    fn schema_id() -> Cow<'static, str> {
875        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("serde_with::OneOrMany({0},PreferOne)",
                <WrapSchema<T, TA>>::schema_id()))
    })std::format!(
876            "serde_with::OneOrMany({},PreferOne)",
877            <WrapSchema<T, TA>>::schema_id()
878        )
879        .into()
880    }
881
882    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
883        let single = gen.subschema_for::<WrapSchema<T, TA>>();
884        let array = SchemaObject {
885            instance_type: Some(InstanceType::Array.into()),
886            array: Some(Box::new(ArrayValidation {
887                items: Some(single.clone().into()),
888                ..Default::default()
889            })),
890            ..Default::default()
891        };
892
893        SchemaObject {
894            subschemas: Some(Box::new(SubschemaValidation {
895                any_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([single, array.into()]))std::vec![single, array.into()]),
896                ..Default::default()
897            })),
898            ..Default::default()
899        }
900        .into()
901    }
902}
903
904impl<T, TA> JsonSchemaAs<Vec<T>> for OneOrMany<TA, PreferMany>
905where
906    TA: JsonSchemaAs<T>,
907{
908    fn schema_name() -> String {
909        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("OneOrMany<{0}, PreferMany>",
                <WrapSchema<T, TA>>::schema_name()))
    })std::format!(
910            "OneOrMany<{}, PreferMany>",
911            <WrapSchema<T, TA>>::schema_name()
912        )
913    }
914
915    fn schema_id() -> Cow<'static, str> {
916        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("serde_with::OneOrMany<{0}, PreferMany>",
                <WrapSchema<T, TA>>::schema_id()))
    })std::format!(
917            "serde_with::OneOrMany<{}, PreferMany>",
918            <WrapSchema<T, TA>>::schema_id()
919        )
920        .into()
921    }
922
923    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
924        let inner = gen.subschema_for::<WrapSchema<T, TA>>();
925        let single = SchemaObject {
926            metadata: Some(Box::new(Metadata {
927                write_only: true,
928                ..Default::default()
929            })),
930            subschemas: Some(Box::new(SubschemaValidation {
931                all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([inner.clone()]))std::vec![inner.clone()]),
932                ..Default::default()
933            })),
934            ..Default::default()
935        };
936        let array = SchemaObject {
937            instance_type: Some(InstanceType::Array.into()),
938            array: Some(Box::new(ArrayValidation {
939                items: Some(Schema::from(single.clone()).into()),
940                ..Default::default()
941            })),
942            ..Default::default()
943        };
944
945        SchemaObject {
946            subschemas: Some(Box::new(SubschemaValidation {
947                any_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([single.into(), array.into()]))std::vec![single.into(), array.into()]),
948                ..Default::default()
949            })),
950            ..Default::default()
951        }
952        .into()
953    }
954}
955
956macro_rules! schema_for_pickfirst {
957    ($( $param:ident )+) => {
958        impl<T, $($param,)+> JsonSchemaAs<T> for PickFirst<($( $param, )+)>
959        where
960            $( $param: JsonSchemaAs<T>, )+
961        {
962            fn schema_name() -> String {
963                std::format!(
964                    concat!(
965                        "PickFirst(",
966                        $( "{", stringify!($param), "}", )+
967                        ")"
968                    ),
969                    $( $param = <WrapSchema<T, $param>>::schema_name(), )+
970                )
971            }
972
973            fn schema_id() -> Cow<'static, str> {
974                std::format!(
975                    concat!(
976                        "serde_with::PickFirst(",
977                        $( "{", stringify!($param), "}", )+
978                        ")"
979                    ),
980                    $( $param = <WrapSchema<T, $param>>::schema_id(), )+
981                )
982                .into()
983            }
984
985            fn json_schema(g: &mut SchemaGenerator) -> Schema {
986                let mut first = true;
987                let subschemas = std::vec![$(
988                    {
989                        let is_first = std::mem::replace(&mut first, false);
990                        let schema = g.subschema_for::<WrapSchema<T, $param>>();
991
992                        if !is_first {
993                            SchemaObject {
994                                metadata: Some(Box::new(Metadata {
995                                    write_only: true,
996                                    ..Default::default()
997                                })),
998                                subschemas: Some(Box::new(SubschemaValidation {
999                                    all_of: Some(std::vec![schema]),
1000                                    ..Default::default()
1001                                })),
1002                                ..Default::default()
1003                            }
1004                            .into()
1005                        } else {
1006                            schema
1007                        }
1008                    }
1009                ),+];
1010
1011                SchemaObject {
1012                    subschemas: Some(Box::new(SubschemaValidation {
1013                        any_of: Some(subschemas),
1014                        ..Default::default()
1015                    })),
1016                    ..Default::default()
1017                }
1018                .into()
1019            }
1020        }
1021    }
1022}
1023
1024impl<T, A> JsonSchemaAs<T> for PickFirst<(A,)> where A: JsonSchemaAs<T> {
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("PickFirst({0})",
                        <WrapSchema<T, A>>::schema_name()))
            })
    }
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::PickFirst({0})",
                            <WrapSchema<T, A>>::schema_id()))
                }).into()
    }
    fn json_schema(g: &mut SchemaGenerator) -> Schema {
        let mut first = true;
        let subschemas =
            <[_]>::into_vec(::alloc::boxed::box_new([{
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, A>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            }]));
        SchemaObject {
                subschemas: Some(Box::new(SubschemaValidation {
                            any_of: Some(subschemas),
                            ..Default::default()
                        })),
                ..Default::default()
            }.into()
    }
}schema_for_pickfirst!(A);
1025impl<T, A, B> JsonSchemaAs<T> for PickFirst<(A, B)> where A: JsonSchemaAs<T>,
    B: JsonSchemaAs<T> {
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("PickFirst({0}{1})",
                        <WrapSchema<T, A>>::schema_name(),
                        <WrapSchema<T, B>>::schema_name()))
            })
    }
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::PickFirst({0}{1})",
                            <WrapSchema<T, A>>::schema_id(),
                            <WrapSchema<T, B>>::schema_id()))
                }).into()
    }
    fn json_schema(g: &mut SchemaGenerator) -> Schema {
        let mut first = true;
        let subschemas =
            <[_]>::into_vec(::alloc::boxed::box_new([{
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, A>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            },
                            {
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, B>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            }]));
        SchemaObject {
                subschemas: Some(Box::new(SubschemaValidation {
                            any_of: Some(subschemas),
                            ..Default::default()
                        })),
                ..Default::default()
            }.into()
    }
}schema_for_pickfirst!(A B);
1026impl<T, A, B, C> JsonSchemaAs<T> for PickFirst<(A, B, C)> where
    A: JsonSchemaAs<T>, B: JsonSchemaAs<T>, C: JsonSchemaAs<T> {
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("PickFirst({0}{1}{2})",
                        <WrapSchema<T, A>>::schema_name(),
                        <WrapSchema<T, B>>::schema_name(),
                        <WrapSchema<T, C>>::schema_name()))
            })
    }
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::PickFirst({0}{1}{2})",
                            <WrapSchema<T, A>>::schema_id(),
                            <WrapSchema<T, B>>::schema_id(),
                            <WrapSchema<T, C>>::schema_id()))
                }).into()
    }
    fn json_schema(g: &mut SchemaGenerator) -> Schema {
        let mut first = true;
        let subschemas =
            <[_]>::into_vec(::alloc::boxed::box_new([{
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, A>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            },
                            {
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, B>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            },
                            {
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, C>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            }]));
        SchemaObject {
                subschemas: Some(Box::new(SubschemaValidation {
                            any_of: Some(subschemas),
                            ..Default::default()
                        })),
                ..Default::default()
            }.into()
    }
}schema_for_pickfirst!(A B C);
1027impl<T, A, B, C, D> JsonSchemaAs<T> for PickFirst<(A, B, C, D)> where
    A: JsonSchemaAs<T>, B: JsonSchemaAs<T>, C: JsonSchemaAs<T>,
    D: JsonSchemaAs<T> {
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("PickFirst({0}{1}{2}{3})",
                        <WrapSchema<T, A>>::schema_name(),
                        <WrapSchema<T, B>>::schema_name(),
                        <WrapSchema<T, C>>::schema_name(),
                        <WrapSchema<T, D>>::schema_name()))
            })
    }
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::PickFirst({0}{1}{2}{3})",
                            <WrapSchema<T, A>>::schema_id(),
                            <WrapSchema<T, B>>::schema_id(),
                            <WrapSchema<T, C>>::schema_id(),
                            <WrapSchema<T, D>>::schema_id()))
                }).into()
    }
    fn json_schema(g: &mut SchemaGenerator) -> Schema {
        let mut first = true;
        let subschemas =
            <[_]>::into_vec(::alloc::boxed::box_new([{
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, A>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            },
                            {
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, B>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            },
                            {
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, C>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            },
                            {
                                let is_first = std::mem::replace(&mut first, false);
                                let schema = g.subschema_for::<WrapSchema<T, D>>();
                                if !is_first {
                                    SchemaObject {
                                            metadata: Some(Box::new(Metadata {
                                                        write_only: true,
                                                        ..Default::default()
                                                    })),
                                            subschemas: Some(Box::new(SubschemaValidation {
                                                        all_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([schema]))),
                                                        ..Default::default()
                                                    })),
                                            ..Default::default()
                                        }.into()
                                } else { schema }
                            }]));
        SchemaObject {
                subschemas: Some(Box::new(SubschemaValidation {
                            any_of: Some(subschemas),
                            ..Default::default()
                        })),
                ..Default::default()
            }.into()
    }
}schema_for_pickfirst!(A B C D);
1028
1029macro_rules! map_first_last_wins_schema {
1030    ($(=> $extra:ident)? $type:ty) => {
1031        impl<V, $($extra,)? VA> JsonSchemaAs<$type> for SetLastValueWins<VA>
1032        where
1033            VA: JsonSchemaAs<V>,
1034        {
1035            fn schema_id() -> Cow<'static, str> {
1036                std::format!(
1037                    "serde_with::SetLastValueWins<{}>",
1038                    <WrapSchema<V, VA> as JsonSchema>::schema_id()
1039                )
1040                .into()
1041            }
1042
1043            fn schema_name() -> String {
1044                std::format!(
1045                    "SetLastValueWins<{}>",
1046                    <WrapSchema<V, VA> as JsonSchema>::schema_name()
1047                )
1048            }
1049
1050            fn json_schema(gen: &mut SchemaGenerator) -> Schema {
1051                let schema = <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
1052                let mut schema = schema.into_object();
1053
1054                // We explicitly allow duplicate items since the whole point of
1055                // SetLastValueWins is to take the duplicate value.
1056                if let Some(array) = &mut schema.array {
1057                    array.unique_items = None;
1058                }
1059
1060                schema.into()
1061            }
1062
1063            fn is_referenceable() -> bool {
1064                false
1065            }
1066        }
1067
1068        impl<V, $($extra,)? VA> JsonSchemaAs<$type> for SetPreventDuplicates<VA>
1069        where
1070            VA: JsonSchemaAs<V>,
1071        {
1072            forward_schema!(BTreeSet<WrapSchema<V, VA>>);
1073        }
1074    }
1075}
1076
1077impl<V, VA> JsonSchemaAs<BTreeSet<V>> for SetLastValueWins<VA> where
    VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, VA> JsonSchemaAs<BTreeSet<V>> for SetPreventDuplicates<VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(BTreeSet<V>);
1078#[cfg(feature = "std")]
1079impl<V, S, VA> JsonSchemaAs<HashSet<V, S>> for SetLastValueWins<VA> where
    VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, S, VA> JsonSchemaAs<HashSet<V, S>> for SetPreventDuplicates<VA> where
    VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S HashSet<V, S>);
1080#[cfg(feature = "hashbrown_0_14")]
1081impl<V, S, VA> JsonSchemaAs<hashbrown_0_14::HashSet<V, S>> for
    SetLastValueWins<VA> where VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, S, VA> JsonSchemaAs<hashbrown_0_14::HashSet<V, S>> for
    SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S hashbrown_0_14::HashSet<V, S>);
1082#[cfg(feature = "hashbrown_0_15")]
1083impl<V, S, VA> JsonSchemaAs<hashbrown_0_15::HashSet<V, S>> for
    SetLastValueWins<VA> where VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, S, VA> JsonSchemaAs<hashbrown_0_15::HashSet<V, S>> for
    SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S hashbrown_0_15::HashSet<V, S>);
1084#[cfg(feature = "hashbrown_0_16")]
1085impl<V, S, VA> JsonSchemaAs<hashbrown_0_16::HashSet<V, S>> for
    SetLastValueWins<VA> where VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, S, VA> JsonSchemaAs<hashbrown_0_16::HashSet<V, S>> for
    SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S hashbrown_0_16::HashSet<V, S>);
1086#[cfg(feature = "indexmap_1")]
1087impl<V, S, VA> JsonSchemaAs<indexmap_1::IndexSet<V, S>> for
    SetLastValueWins<VA> where VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, S, VA> JsonSchemaAs<indexmap_1::IndexSet<V, S>> for
    SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S indexmap_1::IndexSet<V, S>);
1088#[cfg(feature = "indexmap_2")]
1089impl<V, S, VA> JsonSchemaAs<indexmap_2::IndexSet<V, S>> for
    SetLastValueWins<VA> where VA: JsonSchemaAs<V> {
    fn schema_id() -> Cow<'static, str> {
        ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("serde_with::SetLastValueWins<{0}>",
                            <WrapSchema<V, VA> as JsonSchema>::schema_id()))
                }).into()
    }
    fn schema_name() -> String {
        ::alloc::__export::must_use({
                ::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
                        <WrapSchema<V, VA> as JsonSchema>::schema_name()))
            })
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        let schema =
            <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen);
        let mut schema = schema.into_object();
        if let Some(array) = &mut schema.array { array.unique_items = None; }
        schema.into()
    }
    fn is_referenceable() -> bool { false }
}
impl<V, S, VA> JsonSchemaAs<indexmap_2::IndexSet<V, S>> for
    SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
    fn schema_name() -> String {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::is_referenceable()
    }
}map_first_last_wins_schema!(=> S indexmap_2::IndexSet<V, S>);
1090
1091impl<SEP, T, TA> JsonSchemaAs<T> for StringWithSeparator<SEP, TA>
1092where
1093    SEP: Separator,
1094{
1095    <String as JsonSchema>::schema_name();
<String as JsonSchema>::schema_id();
gen
<String as JsonSchema>::json_schema(gen);
<String as JsonSchema>::is_referenceable();forward_schema!(String);
1096}
1097
1098impl<T, TA> JsonSchemaAs<Vec<T>> for VecSkipError<TA>
1099where
1100    TA: JsonSchemaAs<T>,
1101{
1102    <Vec<WrapSchema<T, TA>> as JsonSchema>::schema_name();
<Vec<WrapSchema<T, TA>> as JsonSchema>::schema_id();
gen
<Vec<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
<Vec<WrapSchema<T, TA>> as JsonSchema>::is_referenceable();forward_schema!(Vec<WrapSchema<T, TA>>);
1103}
1104
1105mod timespan {
1106    use super::*;
1107
1108    // #[non_exhaustive] is not actually necessary here but it should
1109    // help avoid warnings about semver breakage if this ever changes.
1110    #[non_exhaustive]
1111    pub enum TimespanTargetType {
1112        String,
1113        F64,
1114        U64,
1115        I64,
1116    }
1117
1118    /// Internal helper trait used to constrain which types we implement
1119    /// `JsonSchemaAs<T>` for.
1120    pub trait TimespanSchemaTarget<F> {
1121        /// The underlying type.
1122        ///
1123        /// This is mainly used to decide which variant of the resulting schema
1124        /// should be marked as `write_only: true`.
1125        const TYPE: TimespanTargetType;
1126
1127        /// Whether the target type is signed.
1128        ///
1129        /// This is only true for `std::time::Duration`.
1130        const SIGNED: bool = true;
1131    }
1132
1133    macro_rules! timespan_type_of {
1134        (String) => {
1135            TimespanTargetType::String
1136        };
1137        (f64) => {
1138            TimespanTargetType::F64
1139        };
1140        (i64) => {
1141            TimespanTargetType::I64
1142        };
1143        (u64) => {
1144            TimespanTargetType::U64
1145        };
1146    }
1147
1148    macro_rules! declare_timespan_target {
1149        ( $target:ty { $($format:ident),* $(,)? } ) => {
1150            $(
1151                impl TimespanSchemaTarget<$format> for $target {
1152                    const TYPE: TimespanTargetType = timespan_type_of!($format);
1153                }
1154            )*
1155        }
1156    }
1157
1158    impl TimespanSchemaTarget<u64> for Duration {
1159        const TYPE: TimespanTargetType = TimespanTargetType::U64;
1160        const SIGNED: bool = false;
1161    }
1162
1163    impl TimespanSchemaTarget<f64> for Duration {
1164        const TYPE: TimespanTargetType = TimespanTargetType::F64;
1165        const SIGNED: bool = false;
1166    }
1167
1168    impl TimespanSchemaTarget<String> for Duration {
1169        const TYPE: TimespanTargetType = TimespanTargetType::String;
1170        const SIGNED: bool = false;
1171    }
1172
1173    impl TimespanSchemaTarget<String> for SystemTime {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(SystemTime { i64, f64, String });
1174
1175    #[cfg(feature = "chrono_0_4")]
1176    impl TimespanSchemaTarget<String> for ::chrono_0_4::Duration {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::chrono_0_4::Duration { i64, f64, String });
1177    #[cfg(feature = "chrono_0_4")]
1178    impl TimespanSchemaTarget<String> for
    ::chrono_0_4::DateTime<::chrono_0_4::Utc> {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::chrono_0_4::DateTime<::chrono_0_4::Utc> { i64, f64, String });
1179    #[cfg(feature = "chrono_0_4")]
1180    impl TimespanSchemaTarget<String> for
    ::chrono_0_4::DateTime<::chrono_0_4::Local> {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::chrono_0_4::DateTime<::chrono_0_4::Local> { i64, f64, String });
1181    #[cfg(feature = "chrono_0_4")]
1182    impl TimespanSchemaTarget<String> for ::chrono_0_4::NaiveDateTime {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::chrono_0_4::NaiveDateTime { i64, f64, String });
1183
1184    #[cfg(feature = "time_0_3")]
1185    impl TimespanSchemaTarget<String> for ::time_0_3::Duration {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::time_0_3::Duration { i64, f64, String });
1186    #[cfg(feature = "time_0_3")]
1187    impl TimespanSchemaTarget<String> for ::time_0_3::OffsetDateTime {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::time_0_3::OffsetDateTime { i64, f64, String });
1188    #[cfg(feature = "time_0_3")]
1189    impl TimespanSchemaTarget<String> for ::time_0_3::PrimitiveDateTime {
    const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::time_0_3::PrimitiveDateTime { i64, f64, String });
1190}
1191
1192use self::timespan::{TimespanSchemaTarget, TimespanTargetType};
1193
1194/// Internal type used for the base impls on `DurationXXX` and `TimestampYYY` types.
1195///
1196/// This allows the `JsonSchema` impls that are Strict to be generic without
1197/// committing to it as part of the public API.
1198struct Timespan<Format, Strictness>(PhantomData<(Format, Strictness)>);
1199
1200impl<T, F> JsonSchemaAs<T> for Timespan<F, Strict>
1201where
1202    T: TimespanSchemaTarget<F>,
1203    F: Format + JsonSchema,
1204{
1205    <F as JsonSchema>::schema_name();
<F as JsonSchema>::schema_id();
gen
<F as JsonSchema>::json_schema(gen);
<F as JsonSchema>::is_referenceable();forward_schema!(F);
1206}
1207
1208impl TimespanTargetType {
1209    pub(crate) fn into_flexible_schema(self, signed: bool) -> Schema {
1210        use ::schemars_0_8::schema::StringValidation;
1211
1212        let mut number = SchemaObject {
1213            instance_type: Some(InstanceType::Number.into()),
1214            number: (!signed).then(|| {
1215                Box::new(NumberValidation {
1216                    minimum: Some(0.0),
1217                    ..Default::default()
1218                })
1219            }),
1220            ..Default::default()
1221        };
1222
1223        // This is a more lenient version of the regex used to determine
1224        // whether JSON numbers are valid. Specifically, it allows multiple
1225        // leading zeroes whereas that is illegal in JSON.
1226        let regex = r#"[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?"#;
1227        let mut string = SchemaObject {
1228            instance_type: Some(InstanceType::String.into()),
1229            string: Some(Box::new(StringValidation {
1230                pattern: Some(match signed {
1231                    true => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("^-?{0}$", regex))
    })std::format!("^-?{regex}$"),
1232                    false => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("^{0}$", regex))
    })std::format!("^{regex}$"),
1233                }),
1234                ..Default::default()
1235            })),
1236            ..Default::default()
1237        };
1238
1239        if #[allow(non_exhaustive_omitted_patterns)] match self {
    Self::String => true,
    _ => false,
}matches!(self, Self::String) {
1240            number.metadata().write_only = true;
1241        } else {
1242            string.metadata().write_only = true;
1243        }
1244
1245        SchemaObject {
1246            subschemas: Some(Box::new(SubschemaValidation {
1247                one_of: Some(<[_]>::into_vec(::alloc::boxed::box_new([number.into(), string.into()]))std::vec![number.into(), string.into()]),
1248                ..Default::default()
1249            })),
1250            ..Default::default()
1251        }
1252        .into()
1253    }
1254
1255    pub(crate) fn schema_id(self) -> &'static str {
1256        match self {
1257            Self::String => "serde_with::FlexibleStringTimespan",
1258            Self::F64 => "serde_with::FlexibleF64Timespan",
1259            Self::U64 => "serde_with::FlexibleU64Timespan",
1260            Self::I64 => "serde_with::FlexibleI64Timespan",
1261        }
1262    }
1263}
1264
1265impl<T, F> JsonSchemaAs<T> for Timespan<F, Flexible>
1266where
1267    T: TimespanSchemaTarget<F>,
1268    F: Format + JsonSchema,
1269{
1270    fn schema_name() -> String {
1271        <T as TimespanSchemaTarget<F>>::TYPE
1272            .schema_id()
1273            .strip_prefix("serde_with::")
1274            .expect("schema id did not start with `serde_with::` - this is a bug")
1275            .into()
1276    }
1277
1278    fn schema_id() -> Cow<'static, str> {
1279        <T as TimespanSchemaTarget<F>>::TYPE.schema_id().into()
1280    }
1281
1282    fn json_schema(_: &mut SchemaGenerator) -> Schema {
1283        <T as TimespanSchemaTarget<F>>::TYPE
1284            .into_flexible_schema(<T as TimespanSchemaTarget<F>>::SIGNED)
1285    }
1286
1287    fn is_referenceable() -> bool {
1288        false
1289    }
1290}
1291
1292macro_rules! forward_duration_schema {
1293    ($ty:ident) => {
1294        impl<T, F> JsonSchemaAs<T> for $ty<F, Strict>
1295        where
1296            T: TimespanSchemaTarget<F>,
1297            F: Format + JsonSchema
1298        {
1299            forward_schema!(WrapSchema<T, Timespan<F, Strict>>);
1300        }
1301
1302        impl<T, F> JsonSchemaAs<T> for $ty<F, Flexible>
1303        where
1304            T: TimespanSchemaTarget<F>,
1305            F: Format + JsonSchema
1306        {
1307            forward_schema!(WrapSchema<T, Timespan<F, Flexible>>);
1308        }
1309    };
1310}
1311
1312impl<T, F> JsonSchemaAs<T> for DurationSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationSeconds);
1313impl<T, F> JsonSchemaAs<T> for DurationMilliSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationMilliSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationMilliSeconds);
1314impl<T, F> JsonSchemaAs<T> for DurationMicroSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationMicroSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationMicroSeconds);
1315impl<T, F> JsonSchemaAs<T> for DurationNanoSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationNanoSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationNanoSeconds);
1316
1317impl<T, F> JsonSchemaAs<T> for DurationSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationSecondsWithFrac<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationSecondsWithFrac);
1318impl<T, F> JsonSchemaAs<T> for DurationMilliSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationMilliSecondsWithFrac<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationMilliSecondsWithFrac);
1319impl<T, F> JsonSchemaAs<T> for DurationMicroSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationMicroSecondsWithFrac<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationMicroSecondsWithFrac);
1320impl<T, F> JsonSchemaAs<T> for DurationNanoSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for DurationNanoSecondsWithFrac<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(DurationNanoSecondsWithFrac);
1321
1322impl<T, F> JsonSchemaAs<T> for TimestampSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampSeconds);
1323impl<T, F> JsonSchemaAs<T> for TimestampMilliSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampMilliSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampMilliSeconds);
1324impl<T, F> JsonSchemaAs<T> for TimestampMicroSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampMicroSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampMicroSeconds);
1325impl<T, F> JsonSchemaAs<T> for TimestampNanoSeconds<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampNanoSeconds<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampNanoSeconds);
1326
1327impl<T, F> JsonSchemaAs<T> for TimestampSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampSecondsWithFrac<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampSecondsWithFrac);
1328impl<T, F> JsonSchemaAs<T> for TimestampMilliSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampMilliSecondsWithFrac<F, Flexible>
    where T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampMilliSecondsWithFrac);
1329impl<T, F> JsonSchemaAs<T> for TimestampMicroSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampMicroSecondsWithFrac<F, Flexible>
    where T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampMicroSecondsWithFrac);
1330impl<T, F> JsonSchemaAs<T> for TimestampNanoSecondsWithFrac<F, Strict> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::is_referenceable()
    }
}
impl<T, F> JsonSchemaAs<T> for TimestampNanoSecondsWithFrac<F, Flexible> where
    T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
    fn schema_name() -> String {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_name()
    }
    fn schema_id() -> Cow<'static, str> {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::schema_id()
    }
    fn json_schema(gen: &mut SchemaGenerator) -> Schema {
        <WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::json_schema(gen)
    }
    fn is_referenceable() -> bool {
        <WrapSchema<T, Timespan<F, Flexible>> as
                JsonSchema>::is_referenceable()
    }
}forward_duration_schema!(TimestampNanoSecondsWithFrac);
1331
1332#[cfg(feature = "json")]
1333impl<T> JsonSchemaAs<T> for json::JsonString {
1334    <String as JsonSchema>::schema_name();
<String as JsonSchema>::schema_id();
gen
<String as JsonSchema>::json_schema(gen);
<String as JsonSchema>::is_referenceable();forward_schema!(String);
1335}