1use crate::{
9 formats::{Flexible, Format, PreferMany, PreferOne, Separator, Strict},
10 prelude::{Schema as WrapSchema, *},
11 utils::NumberExt as _,
12};
13use ::schemars_1::{json_schema, JsonSchema, Schema, SchemaGenerator};
14use alloc::{
15 borrow::Cow,
16 collections::{BTreeMap, BTreeSet},
17 format,
18 rc::Rc,
19 vec::Vec,
20};
21use serde_json::Value;
22
23pub trait JsonSchemaAs<T: ?Sized> {
100 fn inline_schema() -> bool {
110 false
111 }
112
113 fn schema_name() -> Cow<'static, str>;
120
121 fn schema_id() -> Cow<'static, str> {
129 Self::schema_name()
130 }
131
132 fn json_schema(generator: &mut SchemaGenerator) -> Schema;
139}
140
141impl<T, TA> JsonSchema for WrapSchema<T, TA>
142where
143 T: ?Sized,
144 TA: JsonSchemaAs<T>,
145{
146 fn schema_name() -> Cow<'static, str> {
147 TA::schema_name()
148 }
149
150 fn schema_id() -> Cow<'static, str> {
151 TA::schema_id()
152 }
153
154 fn json_schema(generator: &mut SchemaGenerator) -> Schema {
155 TA::json_schema(generator)
156 }
157
158 fn inline_schema() -> bool {
159 TA::inline_schema()
160 }
161}
162
163macro_rules! forward_schema {
167 ($fwd:ty) => {
168 fn schema_name() -> Cow<'static, str> {
169 <$fwd as JsonSchema>::schema_name()
170 }
171
172 fn schema_id() -> Cow<'static, str> {
173 <$fwd as JsonSchema>::schema_id()
174 }
175
176 fn json_schema(gen: &mut SchemaGenerator) -> Schema {
177 <$fwd as JsonSchema>::json_schema(gen)
178 }
179
180 fn inline_schema() -> bool {
181 <$fwd as JsonSchema>::inline_schema()
182 }
183 };
184}
185
186impl<'a, T: 'a, TA: 'a> JsonSchemaAs<&'a T> for &'a TA
190where
191 T: ?Sized,
192 TA: JsonSchemaAs<T>,
193{
194 Cow<'static, str>
<&'a WrapSchema<T, TA> as JsonSchema>::schema_name();
Cow<'static, str>
<&'a WrapSchema<T, TA> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<&'a WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
bool
<&'a WrapSchema<T, TA> as JsonSchema>::inline_schema();forward_schema!(&'a WrapSchema<T, TA>);
195}
196
197impl<'a, T: 'a, TA: 'a> JsonSchemaAs<&'a mut T> for &'a mut TA
198where
199 T: ?Sized,
200 TA: JsonSchemaAs<T>,
201{
202 Cow<'static, str>
<&'a mut WrapSchema<T, TA> as JsonSchema>::schema_name();
Cow<'static, str>
<&'a mut WrapSchema<T, TA> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<&'a mut WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
bool
<&'a mut WrapSchema<T, TA> as JsonSchema>::inline_schema();forward_schema!(&'a mut WrapSchema<T, TA>);
203}
204
205impl<T, TA> JsonSchemaAs<Option<T>> for Option<TA>
206where
207 TA: JsonSchemaAs<T>,
208{
209 Cow<'static, str>
<Option<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Option<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Option<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Option<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Option<WrapSchema<T, TA>>);
210}
211
212impl<T, TA> JsonSchemaAs<Box<T>> for Box<TA>
213where
214 T: ?Sized,
215 TA: JsonSchemaAs<T>,
216{
217 Cow<'static, str>
<Box<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Box<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Box<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Box<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Box<WrapSchema<T, TA>>);
218}
219
220impl<T, TA> JsonSchemaAs<Rc<T>> for Rc<TA>
221where
222 T: ?Sized,
223 TA: JsonSchemaAs<T>,
224{
225 Cow<'static, str>
<Rc<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Rc<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Rc<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Rc<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Rc<WrapSchema<T, TA>>);
226}
227
228impl<T, TA> JsonSchemaAs<Arc<T>> for Arc<TA>
229where
230 T: ?Sized,
231 TA: JsonSchemaAs<T>,
232{
233 Cow<'static, str>
<Arc<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Arc<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Arc<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Arc<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Arc<WrapSchema<T, TA>>);
234}
235
236impl<T, TA> JsonSchemaAs<Vec<T>> for Vec<TA>
237where
238 TA: JsonSchemaAs<T>,
239{
240 Cow<'static, str>
<Vec<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Vec<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Vec<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Vec<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Vec<WrapSchema<T, TA>>);
241}
242
243impl<T, TA> JsonSchemaAs<VecDeque<T>> for VecDeque<TA>
244where
245 TA: JsonSchemaAs<T>,
246{
247 Cow<'static, str>
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<VecDeque<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(VecDeque<WrapSchema<T, TA>>);
248}
249
250impl<K, V, KA, VA> JsonSchemaAs<BTreeMap<K, V>> for BTreeMap<KA, VA>
252where
253 KA: JsonSchemaAs<K>,
254 VA: JsonSchemaAs<V>,
255{
256 Cow<'static, str>
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as JsonSchema>::schema_name();
Cow<'static, str>
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::json_schema(gen);
bool
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema();forward_schema!(BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>>);
257}
258
259#[cfg(feature = "std")]
261impl<K, V, S, KA, VA> JsonSchemaAs<HashMap<K, V, S>> for HashMap<KA, VA, S>
262where
263 KA: JsonSchemaAs<K>,
264 VA: JsonSchemaAs<V>,
265{
266 Cow<'static, str>
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as
JsonSchema>::schema_name();
Cow<'static, str>
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as
JsonSchema>::json_schema(gen);
bool
<HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S> as
JsonSchema>::inline_schema();forward_schema!(HashMap<WrapSchema<K, KA>, WrapSchema<V, VA>, S>);
267}
268
269impl<T, TA> JsonSchemaAs<BTreeSet<T>> for BTreeSet<TA>
270where
271 TA: JsonSchemaAs<T>,
272{
273 Cow<'static, str>
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<BTreeSet<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(BTreeSet<WrapSchema<T, TA>>);
274}
275
276#[cfg(feature = "std")]
277impl<T, TA, S> JsonSchemaAs<T> for HashSet<TA, S>
278where
279 TA: JsonSchemaAs<T>,
280{
281 Cow<'static, str>
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::schema_name();
Cow<'static, str>
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::json_schema(gen);
bool
<HashSet<WrapSchema<T, TA>, S> as JsonSchema>::inline_schema();forward_schema!(HashSet<WrapSchema<T, TA>, S>);
282}
283
284impl<T, TA> JsonSchemaAs<Bound<T>> for Bound<TA>
285where
286 TA: JsonSchemaAs<T>,
287{
288 Cow<'static, str>
<Bound<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Bound<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Bound<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Bound<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Bound<WrapSchema<T, TA>>);
289}
290
291impl<T, TA> JsonSchemaAs<Range<T>> for Range<TA>
292where
293 TA: JsonSchemaAs<T>,
294{
295 Cow<'static, str>
<Range<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Range<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Range<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Range<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Range<WrapSchema<T, TA>>);
296}
297
298impl<T, TA> JsonSchemaAs<RangeInclusive<T>> for RangeInclusive<TA>
314where
315 TA: JsonSchemaAs<T>,
316{
317 Cow<'static, str>
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<RangeInclusive<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(RangeInclusive<WrapSchema<T, TA>>);
318}
319
320impl<T, TA, const N: usize> JsonSchemaAs<[T; N]> for [TA; N]
321where
322 TA: JsonSchemaAs<T>,
323{
324 fn schema_name() -> Cow<'static, str> {
325 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("[{0}; {1}]",
<WrapSchema<T, TA>>::schema_name(), N))
})format!("[{}; {}]", <WrapSchema<T, TA>>::schema_name(), N).into()
326 }
327
328 fn schema_id() -> Cow<'static, str> {
329 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("[{0}; {1}]",
<WrapSchema<T, TA>>::schema_id(), N))
})format!("[{}; {}]", <WrapSchema<T, TA>>::schema_id(), N).into()
330 }
331
332 fn json_schema(generator: &mut SchemaGenerator) -> Schema {
333 let (max, min) = match N.try_into() {
334 Ok(len) => (Some(len), Some(len)),
335 Err(_) => (None, Some(u32::MAX)),
336 };
337
338 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"array").unwrap());
let _ =
object.insert(("items").into(),
::serde_json::to_value(&generator.subschema_for::<WrapSchema<T,
TA>>()).unwrap());
let _ =
object.insert(("maxItems").into(),
::serde_json::to_value(&max).unwrap());
let _ =
object.insert(("minItems").into(),
::serde_json::to_value(&min).unwrap());
object
})).unwrap()json_schema!({
339 "type": "array",
340 "items": generator.subschema_for::<WrapSchema<T, TA>>(),
341 "maxItems": max,
342 "minItems": min
343 })
344 }
345
346 fn inline_schema() -> bool {
347 true
348 }
349}
350
351macro_rules! schema_for_tuple {
352 (
353 ( $( $ts:ident )+ )
354 ( $( $as:ident )+ )
355 ) => {
356 impl<$($ts,)+ $($as,)+> JsonSchemaAs<($($ts,)+)> for ($($as,)+)
357 where
358 $( $as: JsonSchemaAs<$ts>, )+
359 {
360 forward_schema!(( $( WrapSchema<$ts, $as>, )+ ));
361 }
362 }
363}
364
365impl JsonSchemaAs<()> for () {
366 Cow<'static, str>
<() as JsonSchema>::schema_name();
Cow<'static, str>
<() as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<() as JsonSchema>::json_schema(gen);
bool
<() as JsonSchema>::inline_schema();forward_schema!(());
367}
368
369impl<T0, A0> JsonSchemaAs<(T0,)> for (A0,) where A0: JsonSchemaAs<T0> {
fn schema_name() -> Cow<'static, str> {
<(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 inline_schema() -> bool {
<(WrapSchema<T0, A0>,) as JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0)(A0));
372impl<T0, T1, A0, A1> JsonSchemaAs<(T0, T1)> for (A0, A1) where
A0: JsonSchemaAs<T0>, A1: JsonSchemaAs<T1> {
fn schema_name() -> Cow<'static, str> {
<(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 inline_schema() -> bool {
<(WrapSchema<T0, A0>, WrapSchema<T1, A1>) as
JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0 T1) (A0 A1));
373impl<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() -> Cow<'static, str> {
<(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 inline_schema() -> bool {
<(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>) as
JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2) (A0 A1 A2));
374impl<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() -> Cow<'static, str> {
<(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 inline_schema() -> bool {
<(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
WrapSchema<T3, A3>) as JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3) (A0 A1 A2 A3));
375impl<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() -> Cow<'static, str> {
<(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 inline_schema() -> bool {
<(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
WrapSchema<T3, A3>, WrapSchema<T4, A4>) as
JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3 T4) (A0 A1 A2 A3 A4));
376impl<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() -> Cow<'static, str> {
<(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 inline_schema() -> bool {
<(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>) as
JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3 T4 T5) (A0 A1 A2 A3 A4 A5));
377impl<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() -> 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_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 inline_schema() -> bool {
<(WrapSchema<T0, A0>, WrapSchema<T1, A1>, WrapSchema<T2, A2>,
WrapSchema<T3, A3>, WrapSchema<T4, A4>, WrapSchema<T5, A5>,
WrapSchema<T6, A6>) as JsonSchema>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6) (A0 A1 A2 A3 A4 A5 A6));
378impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7) (A0 A1 A2 A3 A4 A5 A6 A7));
379impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7 T8) (A0 A1 A2 A3 A4 A5 A6 A7 A8));
380impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!((T0 T1 T2 T3 T4 T5 T6 T7 T8 T9) (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9));
381impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}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));
382impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}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));
383impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!(
384 (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12)
385 (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12)
386);
387impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!(
388 (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13)
389 (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13)
390);
391impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!(
392 (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14)
393 (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14)
394);
395impl<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() -> 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_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 inline_schema() -> 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>::inline_schema()
}
}schema_for_tuple!(
396 (T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14 T15)
397 (A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15)
398);
399
400impl<T: JsonSchema> JsonSchemaAs<T> for Same {
404 Cow<'static, str>
<T as JsonSchema>::schema_name();
Cow<'static, str>
<T as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<T as JsonSchema>::json_schema(gen);
bool
<T as JsonSchema>::inline_schema();forward_schema!(T);
405}
406
407impl<T> JsonSchemaAs<T> for DisplayFromStr {
408 Cow<'static, str>
<String as JsonSchema>::schema_name();
Cow<'static, str>
<String as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<String as JsonSchema>::json_schema(gen);
bool
<String as JsonSchema>::inline_schema();forward_schema!(String);
409}
410
411#[cfg(feature = "hex")]
412impl<T, F: formats::Format> JsonSchemaAs<T> for hex::Hex<F> {
413 fn schema_name() -> Cow<'static, str> {
414 "Hex<F>".into()
415 }
416
417 fn schema_id() -> Cow<'static, str> {
418 "serde_with::hex::Hex<F>".into()
419 }
420
421 fn json_schema(_: &mut SchemaGenerator) -> Schema {
422 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"string").unwrap());
let _ =
object.insert(("pattern").into(),
::serde_json::to_value(&r"^(?:[0-9A-Fa-f]{2})*$").unwrap());
;
object
})).unwrap()json_schema!({
423 "type": "string",
424 "pattern": r"^(?:[0-9A-Fa-f]{2})*$",
425 })
426 }
427
428 fn inline_schema() -> bool {
429 true
430 }
431}
432
433impl JsonSchemaAs<bool> for BoolFromInt<Strict> {
434 fn schema_name() -> Cow<'static, str> {
435 "BoolFromInt<Strict>".into()
436 }
437
438 fn schema_id() -> Cow<'static, str> {
439 "serde_with::BoolFromInt<Strict>".into()
440 }
441
442 fn json_schema(_: &mut SchemaGenerator) -> Schema {
443 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"integer").unwrap());
let _ =
object.insert(("minimum").into(),
::serde_json::to_value(&0.0).unwrap());
let _ =
object.insert(("maximum").into(),
::serde_json::to_value(&1.0).unwrap());
object
})).unwrap()json_schema!({
444 "type": "integer",
445 "minimum": 0.0,
446 "maximum": 1.0
447 })
448 }
449
450 fn inline_schema() -> bool {
451 true
452 }
453}
454
455impl JsonSchemaAs<bool> for BoolFromInt<Flexible> {
456 fn schema_name() -> Cow<'static, str> {
457 "BoolFromInt<Flexible>".into()
458 }
459
460 fn schema_id() -> Cow<'static, str> {
461 "serde_with::BoolFromInt<Flexible>".into()
462 }
463
464 fn json_schema(_: &mut SchemaGenerator) -> Schema {
465 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"integer").unwrap());
;
object
})).unwrap()json_schema!({
466 "type": "integer",
467 })
468 }
469
470 fn inline_schema() -> bool {
471 true
472 }
473}
474
475impl<'a, T: 'a> JsonSchemaAs<Cow<'a, T>> for BorrowCow
476where
477 T: ?Sized + ToOwned,
478 Cow<'a, T>: JsonSchema,
479{
480 Cow<'static, str>
<Cow<'a, T> as JsonSchema>::schema_name();
Cow<'static, str>
<Cow<'a, T> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Cow<'a, T> as JsonSchema>::json_schema(gen);
bool
<Cow<'a, T> as JsonSchema>::inline_schema();forward_schema!(Cow<'a, T>);
481}
482
483impl<T> JsonSchemaAs<T> for Bytes {
484 Cow<'static, str>
<Vec<u8> as JsonSchema>::schema_name();
Cow<'static, str>
<Vec<u8> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Vec<u8> as JsonSchema>::json_schema(gen);
bool
<Vec<u8> as JsonSchema>::inline_schema();forward_schema!(Vec<u8>);
485}
486
487impl JsonSchemaAs<Vec<u8>> for BytesOrString {
488 fn schema_name() -> Cow<'static, str> {
489 "BytesOrString".into()
490 }
491
492 fn schema_id() -> Cow<'static, str> {
493 "serde_with::BytesOrString".into()
494 }
495
496 fn json_schema(g: &mut SchemaGenerator) -> Schema {
497 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&g.subschema_for::<Vec<u8>>()).unwrap(),
::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"string").unwrap());
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
object
})]))));
object
})).unwrap()json_schema!({
498 "anyOf": [
499 g.subschema_for::<Vec<u8>>(),
500 {
501 "type": "string",
502 "writeOnly": true
503 }
504 ]
505 })
506 }
507
508 fn inline_schema() -> bool {
509 true
510 }
511}
512
513impl<T, TA> JsonSchemaAs<T> for DefaultOnError<TA>
514where
515 TA: JsonSchemaAs<T>,
516{
517 Cow<'static, str>
<WrapSchema<T, TA> as JsonSchema>::schema_name();
Cow<'static, str>
<WrapSchema<T, TA> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
bool
<WrapSchema<T, TA> as JsonSchema>::inline_schema();forward_schema!(WrapSchema<T, TA>);
518}
519
520impl<T, TA> JsonSchemaAs<T> for DefaultOnNull<TA>
521where
522 TA: JsonSchemaAs<T>,
523{
524 Cow<'static, str>
<Option<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Option<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Option<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Option<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Option<WrapSchema<T, TA>>);
525}
526
527impl<O, T: JsonSchema> JsonSchemaAs<O> for FromInto<T> {
528 Cow<'static, str>
<T as JsonSchema>::schema_name();
Cow<'static, str>
<T as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<T as JsonSchema>::json_schema(gen);
bool
<T as JsonSchema>::inline_schema();forward_schema!(T);
529}
530
531impl<O, T: JsonSchema> JsonSchemaAs<O> for FromIntoRef<T> {
532 Cow<'static, str>
<T as JsonSchema>::schema_name();
Cow<'static, str>
<T as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<T as JsonSchema>::json_schema(gen);
bool
<T as JsonSchema>::inline_schema();forward_schema!(T);
533}
534
535impl<T, U: JsonSchema> JsonSchemaAs<T> for TryFromInto<U> {
536 Cow<'static, str>
<U as JsonSchema>::schema_name();
Cow<'static, str>
<U as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<U as JsonSchema>::json_schema(gen);
bool
<U as JsonSchema>::inline_schema();forward_schema!(U);
537}
538
539impl<T, U: JsonSchema> JsonSchemaAs<T> for TryFromIntoRef<U> {
540 Cow<'static, str>
<U as JsonSchema>::schema_name();
Cow<'static, str>
<U as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<U as JsonSchema>::json_schema(gen);
bool
<U as JsonSchema>::inline_schema();forward_schema!(U);
541}
542
543impl<T, TA, FA> JsonSchemaAs<T> for IfIsHumanReadable<TA, FA>
544where
545 TA: JsonSchemaAs<T>,
546{
547 Cow<'static, str>
<WrapSchema<T, TA> as JsonSchema>::schema_name();
Cow<'static, str>
<WrapSchema<T, TA> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<WrapSchema<T, TA> as JsonSchema>::json_schema(gen);
bool
<WrapSchema<T, TA> as JsonSchema>::inline_schema();forward_schema!(WrapSchema<T, TA>);
550}
551
552macro_rules! schema_for_map {
553 ($type:ty) => {
554 impl<K, V, KA, VA> JsonSchemaAs<$type> for Map<KA, VA>
555 where
556 KA: JsonSchemaAs<K>,
557 VA: JsonSchemaAs<V>,
558 {
559 forward_schema!(WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>>);
560 }
561 };
562}
563
564impl<K, V, KA, VA> JsonSchemaAs<[(K, V)]> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!([(K, V)]);
565impl<K, V, KA, VA> JsonSchemaAs<BTreeSet<(K, V)>> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!(BTreeSet<(K, V)>);
566impl<K, V, KA, VA> JsonSchemaAs<BinaryHeap<(K, V)>> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!(BinaryHeap<(K, V)>);
567impl<K, V, KA, VA> JsonSchemaAs<Box<[(K, V)]>> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!(Box<[(K, V)]>);
568impl<K, V, KA, VA> JsonSchemaAs<LinkedList<(K, V)>> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!(LinkedList<(K, V)>);
569impl<K, V, KA, VA> JsonSchemaAs<Vec<(K, V)>> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!(Vec<(K, V)>);
570impl<K, V, KA, VA> JsonSchemaAs<VecDeque<(K, V)>> for Map<KA, VA> where
KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::inline_schema()
}
}schema_for_map!(VecDeque<(K, V)>);
571
572#[cfg(feature = "std")]
573impl<K, V, S, KA, VA> JsonSchemaAs<HashSet<(K, V), S>> for Map<KA, VA>
574where
575 KA: JsonSchemaAs<K>,
576 VA: JsonSchemaAs<V>,
577{
578 Cow<'static, str>
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_name();
Cow<'static, str>
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::json_schema(gen);
bool
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::inline_schema();forward_schema!(WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>>);
579}
580
581impl<T> JsonSchemaAs<Vec<T>> for EnumMap
582where
583 T: JsonSchema,
584{
585 fn schema_name() -> Cow<'static, str> {
586 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("EnumMap({0})", T::schema_name()))
})format!("EnumMap({})", T::schema_name()).into()
587 }
588
589 fn schema_id() -> Cow<'static, str> {
590 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("serde_with::EnumMap({0})",
T::schema_id()))
})format!("serde_with::EnumMap({})", T::schema_id()).into()
591 }
592
593 fn json_schema(g: &mut SchemaGenerator) -> Schema {
601 let mut inner_schema = T::json_schema(g);
602 let inner = inner_schema.ensure_object();
603
604 let one_of = match inner.get_mut("oneOf") {
605 Some(Value::Array(one_of)) => one_of,
606 _ => return inner_schema,
607 };
608
609 let mut properties = serde_json::Map::new();
610 for schema in one_of {
611 let schema = match schema {
612 Value::Object(schema) => schema,
613 _ => continue,
614 };
615
616 if let Some(Value::Object(props)) = schema.get_mut("properties") {
617 properties.extend(core::mem::take(props));
618 }
619 }
620
621 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"object").unwrap());
let _ =
object.insert(("properties").into(),
::serde_json::to_value(&properties).unwrap());
let _ =
object.insert(("additionalProperties").into(),
::serde_json::Value::Bool(false));
object
})).unwrap()json_schema!({
622 "type": "object",
623 "properties": properties,
624 "additionalProperties": false
625 })
626 }
627
628 fn inline_schema() -> bool {
629 false
630 }
631}
632
633impl<T, TA> WrapSchema<Vec<T>, KeyValueMap<TA>>
634where
635 TA: JsonSchemaAs<T>,
636{
637 fn kvmap_transform_schema_1(g: &mut SchemaGenerator, schema: &mut Schema) {
657 let mut parents = Vec::new();
658
659 let mut value = if let Some(object) = schema.as_object_mut() {
660 Value::Object(core::mem::take(object))
661 } else if let Some(value) = schema.as_bool() {
662 Value::Bool(value)
663 } else {
664 ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
665 };
666
667 Self::kvmap_transform_schema_impl_1(g, &mut value, &mut parents, 0);
668 *schema = Schema::try_from(value).expect("modified value was not an object or boolean");
669 }
670
671 fn kvmap_transform_schema_impl_1(
672 g: &mut SchemaGenerator,
673 schema: &mut Value,
674 parents: &mut Vec<String>,
675 depth: u32,
676 ) {
677 if depth > 8 {
678 return;
679 }
680
681 let mut done = false;
682 let schema = match schema.as_object_mut() {
683 Some(schema) => schema,
684 _ => return,
685 };
686
687 let mut parents = if let Some(reference) = &schema.get("$ref") {
692 let reference = match reference {
693 Value::String(reference) => &**reference,
694 _ => return,
696 };
697
698 let name = match Self::resolve_reference_1(g, reference) {
699 Some(name) => name,
700 None => return,
702 };
703
704 if parents.iter().any(|parent| parent == name) {
706 return;
707 }
708
709 let name = name.to_owned();
710 *schema = match g.definitions().get(&name) {
711 Some(Value::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 let ty = match schema.get("type") {
723 Some(Value::String(ty)) if ty == "object" => Some("object"),
724 Some(Value::String(ty)) if ty == "array" => Some("array"),
725 _ => None,
726 };
727
728 if ty == Some("object") {
729 if let Some(Value::Object(properties)) = schema.get_mut("properties") {
733 done |= properties.remove("$key$").is_some();
734 }
735
736 if let Some(Value::Array(required)) = schema.get_mut("required") {
737 required.retain(|req| match req {
738 Value::String(key) if key == "$key$" => {
739 done = true;
740 false
741 }
742 _ => true,
743 });
744 }
745
746 if let Some(Value::Number(max)) = schema.get_mut("maxProperties") {
747 *max = max.saturating_sub(1);
748 }
749
750 if let Some(Value::Number(min)) = schema.get_mut("minProperties") {
751 *min = min.saturating_sub(1);
752 }
753 }
754
755 if ty == Some("array") {
756 if let Some(Value::Array(items)) = schema.get_mut("prefixItems") {
760 if !items.is_empty() {
763 items.remove(0);
764 done = true;
765 }
766 }
767
768 if let Some(Value::Array(items)) = schema.get_mut("items") {
769 if !items.is_empty() {
772 items.remove(0);
773 done = true;
774 }
775 }
776
777 if let Some(Value::Number(max)) = schema.get_mut("maxItems") {
778 *max = max.saturating_sub(1);
779 }
780
781 if let Some(Value::Number(min)) = schema.get_mut("minItems") {
782 *min = min.saturating_sub(1);
783 }
784 }
785
786 if done {
788 return;
789 }
790
791 if let Some(Value::Array(one_of)) = schema.get_mut("oneOf") {
792 for subschema in one_of {
793 Self::kvmap_transform_schema_impl_1(g, subschema, &mut parents, depth + 1);
794 }
795 }
796
797 if let Some(Value::Array(any_of)) = schema.get_mut("anyOf") {
798 for subschema in any_of {
799 Self::kvmap_transform_schema_impl_1(g, subschema, &mut parents, depth + 1);
800 }
801 }
802
803 if let Some(Value::Array(all_of)) = schema.get_mut("allOf") {
804 for subschema in all_of {
805 Self::kvmap_transform_schema_impl_1(g, subschema, &mut parents, depth + 1);
806 }
807 }
808 }
809
810 fn resolve_reference_1<'a>(g: &mut SchemaGenerator, reference: &'a str) -> Option<&'a str> {
811 let reference = reference.strip_prefix('#')?;
814
815 let defpath: &str = &g.settings().definitions_path;
816 let defpath = defpath.strip_prefix("#").unwrap_or(defpath);
817
818 let mut reference = reference.strip_prefix(defpath)?;
819 if !defpath.ends_with('/') {
820 reference = reference.strip_prefix('/').unwrap_or(reference);
821 }
822
823 Some(reference)
824 }
825}
826
827impl<T, TA> JsonSchemaAs<Vec<T>> for KeyValueMap<TA>
828where
829 TA: JsonSchemaAs<T>,
830{
831 fn schema_name() -> Cow<'static, str> {
832 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("KeyValueMap({0})",
<WrapSchema<T, TA>>::schema_name()))
})format!("KeyValueMap({})", <WrapSchema<T, TA>>::schema_name()).into()
833 }
834
835 fn schema_id() -> Cow<'static, str> {
836 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("serde_with::KeyValueMap({0})",
<WrapSchema<T, TA>>::schema_id()))
})format!(
837 "serde_with::KeyValueMap({})",
838 <WrapSchema<T, TA>>::schema_id()
839 )
840 .into()
841 }
842
843 fn json_schema(g: &mut SchemaGenerator) -> Schema {
844 let mut value = <WrapSchema<T, TA>>::json_schema(g);
845 <WrapSchema<Vec<T>, KeyValueMap<TA>>>::kvmap_transform_schema_1(g, &mut value);
846
847 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"object").unwrap());
let _ =
object.insert(("additionalProperties").into(),
::serde_json::to_value(&value).unwrap());
object
})).unwrap()json_schema!({
848 "type": "object",
849 "additionalProperties": value
850 })
851 }
852}
853
854impl<K, V, KA, VA, const N: usize> JsonSchemaAs<[(K, V); N]> for Map<KA, VA>
855where
856 KA: JsonSchemaAs<K>,
857 VA: JsonSchemaAs<V>,
858{
859 Cow<'static, str>
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_name();
Cow<'static, str>
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as
JsonSchema>::json_schema(gen);
bool
<WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>> as JsonSchema>::inline_schema();forward_schema!(WrapSchema<BTreeMap<K, V>, BTreeMap<KA, VA>>);
860}
861
862macro_rules! map_first_last_wins_schema {
863 ($(=> $extra:ident)? $type:ty) => {
864 impl<K, V, $($extra,)? KA, VA> JsonSchemaAs<$type> for MapFirstKeyWins<KA, VA>
865 where
866 KA: JsonSchemaAs<K>,
867 VA: JsonSchemaAs<V>,
868 {
869 forward_schema!(BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>>);
870 }
871
872 impl<K, V, $($extra,)? KA, VA> JsonSchemaAs<$type> for MapPreventDuplicates<KA, VA>
873 where
874 KA: JsonSchemaAs<K>,
875 VA: JsonSchemaAs<V>,
876 {
877 forward_schema!(BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>>);
878 }
879 }
880}
881
882impl<K, V, KA, VA> JsonSchemaAs<BTreeMap<K, V>> for MapFirstKeyWins<KA, VA>
where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, KA, VA> JsonSchemaAs<BTreeMap<K, V>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(BTreeMap<K, V>);
883#[cfg(feature = "std")]
884impl<K, V, S, KA, VA> JsonSchemaAs<HashMap<K, V, S>> for
MapFirstKeyWins<KA, VA> where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, S, KA, VA> JsonSchemaAs<HashMap<K, V, S>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S HashMap<K, V, S>);
885#[cfg(feature = "hashbrown_0_14")]
886impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_14::HashMap<K, V, S>> for
MapFirstKeyWins<KA, VA> where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_14::HashMap<K, V, S>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S hashbrown_0_14::HashMap<K, V, S>);
887#[cfg(feature = "hashbrown_0_15")]
888impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_15::HashMap<K, V, S>> for
MapFirstKeyWins<KA, VA> where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_15::HashMap<K, V, S>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S hashbrown_0_15::HashMap<K, V, S>);
889#[cfg(feature = "hashbrown_0_16")]
890impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_16::HashMap<K, V, S>> for
MapFirstKeyWins<KA, VA> where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, S, KA, VA> JsonSchemaAs<hashbrown_0_16::HashMap<K, V, S>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S hashbrown_0_16::HashMap<K, V, S>);
891#[cfg(feature = "indexmap_1")]
892impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_1::IndexMap<K, V, S>> for
MapFirstKeyWins<KA, VA> where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_1::IndexMap<K, V, S>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S indexmap_1::IndexMap<K, V, S>);
893#[cfg(feature = "indexmap_2")]
894impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_2::IndexMap<K, V, S>> for
MapFirstKeyWins<KA, VA> where KA: JsonSchemaAs<K>, VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}
impl<K, V, S, KA, VA> JsonSchemaAs<indexmap_2::IndexMap<K, V, S>> for
MapPreventDuplicates<KA, VA> where KA: JsonSchemaAs<K>,
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeMap<WrapSchema<K, KA>, WrapSchema<V, VA>> as
JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S indexmap_2::IndexMap<K, V, S>);
895
896impl<T, TA> JsonSchemaAs<Vec<T>> for OneOrMany<TA, PreferOne>
897where
898 TA: JsonSchemaAs<T>,
899{
900 fn schema_name() -> Cow<'static, str> {
901 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("OneOrMany({0},PreferOne)",
<WrapSchema<T, TA>>::schema_name()))
})format!(
902 "OneOrMany({},PreferOne)",
903 <WrapSchema<T, TA>>::schema_name()
904 )
905 .into()
906 }
907
908 fn schema_id() -> Cow<'static, str> {
909 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("serde_with::OneOrMany({0},PreferOne)",
<WrapSchema<T, TA>>::schema_id()))
})format!(
910 "serde_with::OneOrMany({},PreferOne)",
911 <WrapSchema<T, TA>>::schema_id()
912 )
913 .into()
914 }
915
916 fn json_schema(g: &mut SchemaGenerator) -> Schema {
917 let single = g.subschema_for::<WrapSchema<T, TA>>();
918
919 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&single).unwrap(),
::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"array").unwrap());
let _ =
object.insert(("items").into(),
::serde_json::to_value(&single).unwrap());
object
})]))));
object
})).unwrap()json_schema!({
920 "anyOf": [
921 single,
922 {
923 "type": "array",
924 "items": single
925 }
926 ]
927 })
928 }
929}
930
931impl<T, TA> JsonSchemaAs<Vec<T>> for OneOrMany<TA, PreferMany>
932where
933 TA: JsonSchemaAs<T>,
934{
935 fn schema_name() -> Cow<'static, str> {
936 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("OneOrMany<{0}, PreferMany>",
<WrapSchema<T, TA>>::schema_name()))
})format!(
937 "OneOrMany<{}, PreferMany>",
938 <WrapSchema<T, TA>>::schema_name()
939 )
940 .into()
941 }
942
943 fn schema_id() -> Cow<'static, str> {
944 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("serde_with::OneOrMany<{0}, PreferMany>",
<WrapSchema<T, TA>>::schema_id()))
})format!(
945 "serde_with::OneOrMany<{}, PreferMany>",
946 <WrapSchema<T, TA>>::schema_id()
947 )
948 .into()
949 }
950
951 fn json_schema(g: &mut SchemaGenerator) -> Schema {
952 let inner = g.subschema_for::<WrapSchema<T, TA>>();
953
954 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&inner).unwrap()]))));
;
object
}),
::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"array").unwrap());
let _ =
object.insert(("items").into(),
::serde_json::to_value(&inner).unwrap());
object
})]))));
object
})).unwrap()json_schema!({
955 "anyOf": [
956 {
957 "writeOnly": true,
958 "allOf": [
959 inner
960 ],
961 },
962 {
963 "type": "array",
964 "items": inner
965 }
966 ]
967 })
968 }
969}
970
971macro_rules! schema_for_pickfirst {
972 ($( $param:ident )+) => {
973 impl<T, $($param,)+> JsonSchemaAs<T> for PickFirst<($( $param, )+)>
974 where
975 $( $param: JsonSchemaAs<T>, )+
976 {
977 fn schema_name() -> Cow<'static, str> {
978 format!(
979 concat!(
980 "PickFirst(",
981 $( "{", stringify!($param), "}", )+
982 ")"
983 ),
984 $( $param = <WrapSchema<T, $param>>::schema_name(), )+
985 )
986 .into()
987 }
988
989 fn schema_id() -> Cow<'static, str> {
990 format!(
991 concat!(
992 "serde_with::PickFirst(",
993 $( "{", stringify!($param), "}", )+
994 ")"
995 ),
996 $( $param = <WrapSchema<T, $param>>::schema_id(), )+
997 )
998 .into()
999 }
1000
1001 fn json_schema(g: &mut SchemaGenerator) -> Schema {
1002 let mut first = true;
1003 let subschemas = alloc::vec![$(
1004 {
1005 let is_first = core::mem::replace(&mut first, false);
1006 let schema = g.subschema_for::<WrapSchema<T, $param>>();
1007
1008 if !is_first {
1009 json_schema!({
1010 "writeOnly": true,
1011 "allOf": [schema]
1012 })
1013 } else {
1014 schema
1015 }
1016 }
1017 ),+];
1018
1019 json_schema!({
1020 "anyOf": subschemas
1021 })
1022 }
1023 }
1024 }
1025}
1026
1027impl<T, A> JsonSchemaAs<T> for PickFirst<(A,)> where A: JsonSchemaAs<T> {
fn schema_name() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("PickFirst({0})",
<WrapSchema<T, A>>::schema_name()))
}).into()
}
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 =
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, A>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
}]));
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::to_value(&subschemas).unwrap());
object
})).unwrap()
}
}schema_for_pickfirst!(A);
1028impl<T, A, B> JsonSchemaAs<T> for PickFirst<(A, B)> where A: JsonSchemaAs<T>,
B: JsonSchemaAs<T> {
fn schema_name() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("PickFirst({0}{1})",
<WrapSchema<T, A>>::schema_name(),
<WrapSchema<T, B>>::schema_name()))
}).into()
}
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 =
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, A>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
},
{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, B>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
}]));
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::to_value(&subschemas).unwrap());
object
})).unwrap()
}
}schema_for_pickfirst!(A B);
1029impl<T, A, B, C> JsonSchemaAs<T> for PickFirst<(A, B, C)> where
A: JsonSchemaAs<T>, B: JsonSchemaAs<T>, C: JsonSchemaAs<T> {
fn schema_name() -> Cow<'static, str> {
::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()))
}).into()
}
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 =
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, A>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
},
{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, B>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
},
{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, C>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
}]));
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::to_value(&subschemas).unwrap());
object
})).unwrap()
}
}schema_for_pickfirst!(A B C);
1030impl<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() -> Cow<'static, str> {
::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()))
}).into()
}
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 =
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, A>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
},
{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, B>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
},
{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, C>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
},
{
let is_first = core::mem::replace(&mut first, false);
let schema = g.subschema_for::<WrapSchema<T, D>>();
if !is_first {
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("writeOnly").into(),
::serde_json::Value::Bool(true));
let _ =
object.insert(("allOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&schema).unwrap()]))));
object
})).unwrap()
} else { schema }
}]));
::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("anyOf").into(),
::serde_json::to_value(&subschemas).unwrap());
object
})).unwrap()
}
}schema_for_pickfirst!(A B C D);
1031
1032macro_rules! map_first_last_wins_schema {
1033 ($(=> $extra:ident)? $type:ty) => {
1034 impl<V, $($extra,)? VA> JsonSchemaAs<$type> for SetLastValueWins<VA>
1035 where
1036 VA: JsonSchemaAs<V>,
1037 {
1038 fn schema_id() -> Cow<'static, str> {
1039 format!(
1040 "serde_with::SetLastValueWins<{}>",
1041 <WrapSchema<V, VA> as JsonSchema>::schema_id()
1042 )
1043 .into()
1044 }
1045
1046 fn schema_name() -> Cow<'static, str> {
1047 format!(
1048 "SetLastValueWins<{}>",
1049 <WrapSchema<V, VA> as JsonSchema>::schema_name()
1050 )
1051 .into()
1052 }
1053
1054 fn json_schema(g: &mut SchemaGenerator) -> Schema {
1055 let mut schema = <BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
1056 let object = schema.ensure_object();
1057
1058 object.remove("uniqueItems");
1061
1062 schema
1063 }
1064
1065 fn inline_schema() -> bool {
1066 <WrapSchema<V, VA> as JsonSchema>::inline_schema()
1067 }
1068 }
1069
1070 impl<V, $($extra,)? VA> JsonSchemaAs<$type> for SetPreventDuplicates<VA>
1071 where
1072 VA: JsonSchemaAs<V>,
1073 {
1074 forward_schema!(BTreeSet<WrapSchema<V, VA>>);
1075 }
1076 }
1077}
1078
1079impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, VA> JsonSchemaAs<BTreeSet<V>> for SetPreventDuplicates<VA> where
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(BTreeSet<V>);
1080#[cfg(feature = "std")]
1081impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, S, VA> JsonSchemaAs<HashSet<V, S>> for SetPreventDuplicates<VA> where
VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S HashSet<V, S>);
1082#[cfg(feature = "hashbrown_0_14")]
1083impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, S, VA> JsonSchemaAs<hashbrown_0_14::HashSet<V, S>> for
SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S hashbrown_0_14::HashSet<V, S>);
1084#[cfg(feature = "hashbrown_0_15")]
1085impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, S, VA> JsonSchemaAs<hashbrown_0_15::HashSet<V, S>> for
SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S hashbrown_0_15::HashSet<V, S>);
1086#[cfg(feature = "hashbrown_0_16")]
1087impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, S, VA> JsonSchemaAs<hashbrown_0_16::HashSet<V, S>> for
SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S hashbrown_0_16::HashSet<V, S>);
1088#[cfg(feature = "indexmap_1")]
1089impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, S, VA> JsonSchemaAs<indexmap_1::IndexSet<V, S>> for
SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S indexmap_1::IndexSet<V, S>);
1090#[cfg(feature = "indexmap_2")]
1091impl<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() -> Cow<'static, str> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("SetLastValueWins<{0}>",
<WrapSchema<V, VA> as JsonSchema>::schema_name()))
}).into()
}
fn json_schema(g: &mut SchemaGenerator) -> Schema {
let mut schema =
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::json_schema(g);
let object = schema.ensure_object();
object.remove("uniqueItems");
schema
}
fn inline_schema() -> bool {
<WrapSchema<V, VA> as JsonSchema>::inline_schema()
}
}
impl<V, S, VA> JsonSchemaAs<indexmap_2::IndexSet<V, S>> for
SetPreventDuplicates<VA> where VA: JsonSchemaAs<V> {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<BTreeSet<WrapSchema<V, VA>> as JsonSchema>::inline_schema()
}
}map_first_last_wins_schema!(=> S indexmap_2::IndexSet<V, S>);
1092
1093impl<SEP, T, TA> JsonSchemaAs<T> for StringWithSeparator<SEP, TA>
1094where
1095 SEP: Separator,
1096{
1097 Cow<'static, str>
<String as JsonSchema>::schema_name();
Cow<'static, str>
<String as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<String as JsonSchema>::json_schema(gen);
bool
<String as JsonSchema>::inline_schema();forward_schema!(String);
1098}
1099
1100impl<T, TA> JsonSchemaAs<Vec<T>> for VecSkipError<TA>
1101where
1102 TA: JsonSchemaAs<T>,
1103{
1104 Cow<'static, str>
<Vec<WrapSchema<T, TA>> as JsonSchema>::schema_name();
Cow<'static, str>
<Vec<WrapSchema<T, TA>> as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<Vec<WrapSchema<T, TA>> as JsonSchema>::json_schema(gen);
bool
<Vec<WrapSchema<T, TA>> as JsonSchema>::inline_schema();forward_schema!(Vec<WrapSchema<T, TA>>);
1105}
1106
1107mod timespan {
1108 use super::*;
1109
1110 #[non_exhaustive]
1113 pub enum TimespanTargetType {
1114 String,
1115 F64,
1116 U64,
1117 I64,
1118 }
1119
1120 pub trait TimespanSchemaTarget<F> {
1123 const TYPE: TimespanTargetType;
1128
1129 const SIGNED: bool = true;
1133 }
1134
1135 #[cfg_attr(not(feature = "std"), allow(unused_macros))]
1136 macro_rules! timespan_type_of {
1137 (String) => {
1138 TimespanTargetType::String
1139 };
1140 (f64) => {
1141 TimespanTargetType::F64
1142 };
1143 (i64) => {
1144 TimespanTargetType::I64
1145 };
1146 (u64) => {
1147 TimespanTargetType::U64
1148 };
1149 }
1150
1151 #[cfg_attr(not(feature = "std"), allow(unused_macros))]
1152 macro_rules! declare_timespan_target {
1153 ( $target:ty { $($format:ident),* $(,)? } ) => {
1154 $(
1155 impl TimespanSchemaTarget<$format> for $target {
1156 const TYPE: TimespanTargetType = timespan_type_of!($format);
1157 }
1158 )*
1159 }
1160 }
1161
1162 impl TimespanSchemaTarget<u64> for Duration {
1163 const TYPE: TimespanTargetType = TimespanTargetType::U64;
1164 const SIGNED: bool = false;
1165 }
1166
1167 impl TimespanSchemaTarget<f64> for Duration {
1168 const TYPE: TimespanTargetType = TimespanTargetType::F64;
1169 const SIGNED: bool = false;
1170 }
1171
1172 impl TimespanSchemaTarget<String> for Duration {
1173 const TYPE: TimespanTargetType = TimespanTargetType::String;
1174 const SIGNED: bool = false;
1175 }
1176
1177 #[cfg(feature = "std")]
1178 impl TimespanSchemaTarget<String> for SystemTime {
const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(SystemTime { i64, f64, String });
1179
1180 #[cfg(feature = "chrono_0_4")]
1181 impl TimespanSchemaTarget<String> for ::chrono_0_4::Duration {
const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::chrono_0_4::Duration { i64, f64, String });
1182 #[cfg(feature = "chrono_0_4")]
1183 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 });
1184 #[cfg(all(feature = "chrono_0_4", feature = "std"))]
1185 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 });
1186 #[cfg(feature = "chrono_0_4")]
1187 impl TimespanSchemaTarget<String> for ::chrono_0_4::NaiveDateTime {
const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::chrono_0_4::NaiveDateTime { i64, f64, String });
1188
1189 #[cfg(feature = "time_0_3")]
1190 impl TimespanSchemaTarget<String> for ::time_0_3::Duration {
const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::time_0_3::Duration { i64, f64, String });
1191 #[cfg(feature = "time_0_3")]
1192 impl TimespanSchemaTarget<String> for ::time_0_3::OffsetDateTime {
const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::time_0_3::OffsetDateTime { i64, f64, String });
1193 #[cfg(feature = "time_0_3")]
1194 impl TimespanSchemaTarget<String> for ::time_0_3::PrimitiveDateTime {
const TYPE: TimespanTargetType = TimespanTargetType::String;
}declare_timespan_target!(::time_0_3::PrimitiveDateTime { i64, f64, String });
1195}
1196
1197use self::timespan::{TimespanSchemaTarget, TimespanTargetType};
1198
1199struct Timespan<Format, Strictness>(PhantomData<(Format, Strictness)>);
1204
1205impl<T, F> JsonSchemaAs<T> for Timespan<F, Strict>
1206where
1207 T: TimespanSchemaTarget<F>,
1208 F: Format + JsonSchema,
1209{
1210 Cow<'static, str>
<F as JsonSchema>::schema_name();
Cow<'static, str>
<F as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<F as JsonSchema>::json_schema(gen);
bool
<F as JsonSchema>::inline_schema();forward_schema!(F);
1211}
1212
1213impl TimespanTargetType {
1214 pub(crate) fn into_flexible_schema(self, signed: bool) -> Schema {
1215 let mut number = ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"number").unwrap());
object
})).unwrap()json_schema!({
1216 "type": "number"
1217 });
1218
1219 if !signed {
1220 number
1221 .ensure_object()
1222 .insert("minimum".into(), ::serde_json::to_value(&0.0).unwrap()serde_json::json!(0.0));
1223 }
1224
1225 let regex = r#"[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?"#;
1229 let mut string = ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("type").into(),
::serde_json::to_value(&"string").unwrap());
let _ =
object.insert(("pattern").into(),
::serde_json::to_value(&match signed {
true =>
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("^-?{0}$", regex))
}),
false =>
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("^{0}$", regex))
}),
}).unwrap());
object
})).unwrap()json_schema!({
1230 "type": "string",
1231 "pattern": match signed {
1232 true => format!("^-?{regex}$"),
1233 false => format!("^{regex}$"),
1234 }
1235 });
1236
1237 if #[allow(non_exhaustive_omitted_patterns)] match self {
Self::String => true,
_ => false,
}matches!(self, Self::String) {
1238 number
1239 .ensure_object()
1240 .insert("writeOnly".into(), true.into());
1241 } else {
1242 string
1243 .ensure_object()
1244 .insert("writeOnly".into(), true.into());
1245 }
1246
1247 ::schemars::Schema::try_from(::serde_json::Value::Object({
let mut object = ::serde_json::Map::new();
let _ =
object.insert(("oneOf").into(),
::serde_json::Value::Array(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::serde_json::to_value(&number).unwrap(),
::serde_json::to_value(&string).unwrap()]))));
object
})).unwrap()json_schema!({
1248 "oneOf": [number, string]
1249 })
1250 }
1251
1252 pub(crate) fn schema_id(self) -> &'static str {
1253 match self {
1254 Self::String => "serde_with::FlexibleStringTimespan",
1255 Self::F64 => "serde_with::FlexibleF64Timespan",
1256 Self::U64 => "serde_with::FlexibleU64Timespan",
1257 Self::I64 => "serde_with::FlexibleI64Timespan",
1258 }
1259 }
1260}
1261
1262impl<T, F> JsonSchemaAs<T> for Timespan<F, Flexible>
1263where
1264 T: TimespanSchemaTarget<F>,
1265 F: Format + JsonSchema,
1266{
1267 fn schema_name() -> Cow<'static, str> {
1268 <T as TimespanSchemaTarget<F>>::TYPE
1269 .schema_id()
1270 .strip_prefix("serde_with::")
1271 .expect("schema id did not start with `serde_with::` - this is a bug")
1272 .into()
1273 }
1274
1275 fn schema_id() -> Cow<'static, str> {
1276 <T as TimespanSchemaTarget<F>>::TYPE.schema_id().into()
1277 }
1278
1279 fn json_schema(_: &mut SchemaGenerator) -> Schema {
1280 <T as TimespanSchemaTarget<F>>::TYPE
1281 .into_flexible_schema(<T as TimespanSchemaTarget<F>>::SIGNED)
1282 }
1283
1284 fn inline_schema() -> bool {
1285 true
1286 }
1287}
1288
1289macro_rules! forward_duration_schema {
1290 ($ty:ident) => {
1291 impl<T, F> JsonSchemaAs<T> for $ty<F, Strict>
1292 where
1293 T: TimespanSchemaTarget<F>,
1294 F: Format + JsonSchema
1295 {
1296 forward_schema!(WrapSchema<T, Timespan<F, Strict>>);
1297 }
1298
1299 impl<T, F> JsonSchemaAs<T> for $ty<F, Flexible>
1300 where
1301 T: TimespanSchemaTarget<F>,
1302 F: Format + JsonSchema
1303 {
1304 forward_schema!(WrapSchema<T, Timespan<F, Flexible>>);
1305 }
1306 };
1307}
1308
1309impl<T, F> JsonSchemaAs<T> for DurationSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationSeconds);
1310impl<T, F> JsonSchemaAs<T> for DurationMilliSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationMilliSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationMilliSeconds);
1311impl<T, F> JsonSchemaAs<T> for DurationMicroSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationMicroSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationMicroSeconds);
1312impl<T, F> JsonSchemaAs<T> for DurationNanoSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationNanoSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationNanoSeconds);
1313
1314impl<T, F> JsonSchemaAs<T> for DurationSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationSecondsWithFrac<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationSecondsWithFrac);
1315impl<T, F> JsonSchemaAs<T> for DurationMilliSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationMilliSecondsWithFrac<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationMilliSecondsWithFrac);
1316impl<T, F> JsonSchemaAs<T> for DurationMicroSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationMicroSecondsWithFrac<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationMicroSecondsWithFrac);
1317impl<T, F> JsonSchemaAs<T> for DurationNanoSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for DurationNanoSecondsWithFrac<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(DurationNanoSecondsWithFrac);
1318
1319impl<T, F> JsonSchemaAs<T> for TimestampSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampSeconds);
1320impl<T, F> JsonSchemaAs<T> for TimestampMilliSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampMilliSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampMilliSeconds);
1321impl<T, F> JsonSchemaAs<T> for TimestampMicroSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampMicroSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampMicroSeconds);
1322impl<T, F> JsonSchemaAs<T> for TimestampNanoSeconds<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampNanoSeconds<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampNanoSeconds);
1323
1324impl<T, F> JsonSchemaAs<T> for TimestampSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampSecondsWithFrac<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampSecondsWithFrac);
1325impl<T, F> JsonSchemaAs<T> for TimestampMilliSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampMilliSecondsWithFrac<F, Flexible>
where T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampMilliSecondsWithFrac);
1326impl<T, F> JsonSchemaAs<T> for TimestampMicroSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampMicroSecondsWithFrac<F, Flexible>
where T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampMicroSecondsWithFrac);
1327impl<T, F> JsonSchemaAs<T> for TimestampNanoSecondsWithFrac<F, Strict> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Strict>> as JsonSchema>::inline_schema()
}
}
impl<T, F> JsonSchemaAs<T> for TimestampNanoSecondsWithFrac<F, Flexible> where
T: TimespanSchemaTarget<F>, F: Format + JsonSchema {
fn schema_name() -> Cow<'static, str> {
<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 inline_schema() -> bool {
<WrapSchema<T, Timespan<F, Flexible>> as JsonSchema>::inline_schema()
}
}forward_duration_schema!(TimestampNanoSecondsWithFrac);
1328
1329#[cfg(feature = "json")]
1330impl<T> JsonSchemaAs<T> for json::JsonString {
1331 Cow<'static, str>
<String as JsonSchema>::schema_name();
Cow<'static, str>
<String as JsonSchema>::schema_id();
&mut SchemaGenerator
gen
Schema
<String as JsonSchema>::json_schema(gen);
bool
<String as JsonSchema>::inline_schema();forward_schema!(String);
1332}