Fix build warnings from tests
Deriving `Debug` is no longer enough to suppress warnings about unused fields
This commit is contained in:
parent
29d2455bb3
commit
043d794e39
30 changed files with 188 additions and 136 deletions
|
@ -3,7 +3,8 @@ use chrono::prelude::*;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct ChronoTypes {
|
struct ChronoTypes {
|
||||||
weekday: Weekday,
|
weekday: Weekday,
|
||||||
date_time: DateTime<Utc>,
|
date_time: DateTime<Utc>,
|
||||||
|
|
|
@ -5,9 +5,10 @@ use util::*;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std as schemars;
|
use std as schemars;
|
||||||
|
|
||||||
#[derive(Debug, not_schemars::JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(not_schemars::JsonSchema)]
|
||||||
#[schemars(crate = "not_schemars")]
|
#[schemars(crate = "not_schemars")]
|
||||||
pub struct Struct {
|
struct Struct {
|
||||||
/// This is a document
|
/// This is a document
|
||||||
foo: i32,
|
foo: i32,
|
||||||
bar: bool,
|
bar: bool,
|
||||||
|
|
|
@ -24,41 +24,44 @@ where
|
||||||
ser.collect_str(&format_args!("i:{} b:{}", value.my_int, value.my_bool))
|
ser.collect_str(&format_args!("i:{} b:{}", value.my_int, value.my_bool))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, JsonSchema, Debug)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(Default, JsonSchema)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct MyStruct {
|
struct MyStruct {
|
||||||
pub my_int: i32,
|
my_int: i32,
|
||||||
pub my_bool: bool,
|
my_bool: bool,
|
||||||
#[serde(serialize_with = "custom_serialize")]
|
#[serde(serialize_with = "custom_serialize")]
|
||||||
pub my_struct2: MyStruct2,
|
my_struct2: MyStruct2,
|
||||||
#[serde(
|
#[serde(
|
||||||
serialize_with = "custom_serialize",
|
serialize_with = "custom_serialize",
|
||||||
skip_serializing_if = "is_default"
|
skip_serializing_if = "is_default"
|
||||||
)]
|
)]
|
||||||
pub my_struct2_default_skipped: MyStruct2,
|
my_struct2_default_skipped: MyStruct2,
|
||||||
pub not_serialize: NotSerialize,
|
not_serialize: NotSerialize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, JsonSchema, Debug, PartialEq)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(Default, JsonSchema, PartialEq)]
|
||||||
#[serde(default = "ten_and_true")]
|
#[serde(default = "ten_and_true")]
|
||||||
pub struct MyStruct2 {
|
struct MyStruct2 {
|
||||||
#[serde(default = "six")]
|
#[serde(default = "six")]
|
||||||
pub my_int: i32,
|
my_int: i32,
|
||||||
pub my_bool: bool,
|
my_bool: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, JsonSchema, Debug)]
|
#[derive(Default, JsonSchema)]
|
||||||
pub struct NotSerialize;
|
struct NotSerialize;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn schema_default_values() -> TestResult {
|
fn schema_default_values() -> TestResult {
|
||||||
test_default_generated_schema::<MyStruct>("default")
|
test_default_generated_schema::<MyStruct>("default")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JsonSchema, Debug)]
|
#[allow(dead_code)]
|
||||||
pub struct StructWithGenericDefaults {
|
#[derive(JsonSchema)]
|
||||||
|
struct StructWithGenericDefaults {
|
||||||
#[serde(default = "Vec::new")]
|
#[serde(default = "Vec::new")]
|
||||||
pub a_vec: Vec<String>,
|
a_vec: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -4,9 +4,10 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
pub struct DeprecatedStruct {
|
struct DeprecatedStruct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
deprecated_field: bool,
|
deprecated_field: bool,
|
||||||
|
@ -17,9 +18,10 @@ fn deprecated_struct() -> TestResult {
|
||||||
test_default_generated_schema::<DeprecatedStruct>("deprecated-struct")
|
test_default_generated_schema::<DeprecatedStruct>("deprecated-struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
pub enum DeprecatedEnum {
|
enum DeprecatedEnum {
|
||||||
Unit,
|
Unit,
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
DeprecatedUnitVariant,
|
DeprecatedUnitVariant,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use schemars::{gen::SchemaGenerator, JsonSchema};
|
use schemars::{gen::SchemaGenerator, JsonSchema};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct Struct {
|
#[derive(JsonSchema)]
|
||||||
|
struct Struct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
bar: bool,
|
bar: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::{gen::SchemaSettings, JsonSchema};
|
use schemars::{gen::SchemaSettings, JsonSchema};
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* # This is the struct's title
|
* # This is the struct's title
|
||||||
|
@ -10,24 +11,25 @@ use util::*;
|
||||||
* This is the struct's description.
|
* This is the struct's description.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
pub struct MyStruct {
|
struct MyStruct {
|
||||||
/// # An integer
|
/// # An integer
|
||||||
pub my_int: i32,
|
my_int: i32,
|
||||||
pub my_undocumented_bool: bool,
|
my_undocumented_bool: bool,
|
||||||
/// A unit struct instance
|
/// A unit struct instance
|
||||||
pub my_unit: MyUnitStruct,
|
my_unit: MyUnitStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # A Unit
|
/// # A Unit
|
||||||
///
|
///
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct MyUnitStruct;
|
struct MyUnitStruct;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[doc = " # This is the enum's title "]
|
#[doc = " # This is the enum's title "]
|
||||||
#[doc = " This is "]
|
#[doc = " This is "]
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[doc = " the enum's description."]
|
#[doc = " the enum's description."]
|
||||||
pub enum MyEnum {
|
enum MyEnum {
|
||||||
UndocumentedUnit,
|
UndocumentedUnit,
|
||||||
/// This comment is not included in the generated schema :(
|
/// This comment is not included in the generated schema :(
|
||||||
DocumentedUnit,
|
DocumentedUnit,
|
||||||
|
@ -69,16 +71,17 @@ fn doc_comments_enum() -> TestResult {
|
||||||
|
|
||||||
/// # OverrideDocs struct
|
/// # OverrideDocs struct
|
||||||
/// This description should be overridden
|
/// This description should be overridden
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(description = "New description")]
|
#[schemars(description = "New description")]
|
||||||
pub struct OverrideDocs {
|
struct OverrideDocs {
|
||||||
/// # Overridden
|
/// # Overridden
|
||||||
#[schemars(title = "My integer", description = "This is an i32")]
|
#[schemars(title = "My integer", description = "This is an i32")]
|
||||||
pub my_int: i32,
|
my_int: i32,
|
||||||
/// # Overridden
|
/// # Overridden
|
||||||
/// Also overridden
|
/// Also overridden
|
||||||
#[schemars(title = "", description = "")]
|
#[schemars(title = "", description = "")]
|
||||||
pub my_undocumented_bool: bool,
|
my_undocumented_bool: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -5,18 +5,20 @@ use util::*;
|
||||||
// Ensure that schemars_derive uses the full path to std::string::String
|
// Ensure that schemars_derive uses the full path to std::string::String
|
||||||
pub struct String;
|
pub struct String;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct UnitStruct;
|
struct UnitStruct;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct Struct {
|
#[derive(JsonSchema)]
|
||||||
|
struct Struct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
bar: bool,
|
bar: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(rename_all = "camelCase")]
|
#[schemars(rename_all = "camelCase")]
|
||||||
pub enum External {
|
enum External {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -36,9 +38,10 @@ fn enum_external_tag() -> TestResult {
|
||||||
test_default_generated_schema::<External>("enum-external")
|
test_default_generated_schema::<External>("enum-external")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "typeProperty")]
|
#[schemars(tag = "typeProperty")]
|
||||||
pub enum Internal {
|
enum Internal {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -57,9 +60,10 @@ fn enum_internal_tag() -> TestResult {
|
||||||
test_default_generated_schema::<Internal>("enum-internal")
|
test_default_generated_schema::<Internal>("enum-internal")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(untagged)]
|
#[schemars(untagged)]
|
||||||
pub enum Untagged {
|
enum Untagged {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -78,9 +82,10 @@ fn enum_untagged() -> TestResult {
|
||||||
test_default_generated_schema::<Untagged>("enum-untagged")
|
test_default_generated_schema::<Untagged>("enum-untagged")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "t", content = "c")]
|
#[schemars(tag = "t", content = "c")]
|
||||||
pub enum Adjacent {
|
enum Adjacent {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -100,9 +105,10 @@ fn enum_adjacent_tagged() -> TestResult {
|
||||||
test_default_generated_schema::<Adjacent>("enum-adjacent-tagged")
|
test_default_generated_schema::<Adjacent>("enum-adjacent-tagged")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "typeProperty")]
|
#[schemars(tag = "typeProperty")]
|
||||||
pub enum SimpleInternal {
|
enum SimpleInternal {
|
||||||
A,
|
A,
|
||||||
B,
|
B,
|
||||||
C,
|
C,
|
||||||
|
|
|
@ -5,20 +5,22 @@ use util::*;
|
||||||
// Ensure that schemars_derive uses the full path to std::string::String
|
// Ensure that schemars_derive uses the full path to std::string::String
|
||||||
pub struct String;
|
pub struct String;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct UnitStruct;
|
struct UnitStruct;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct Struct {
|
#[derive(JsonSchema)]
|
||||||
|
struct Struct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
bar: bool,
|
bar: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outer container should always have additionalProperties: false
|
// Outer container should always have additionalProperties: false
|
||||||
// `Struct` variant should have additionalProperties: false
|
// `Struct` variant should have additionalProperties: false
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(rename_all = "camelCase", deny_unknown_fields)]
|
#[schemars(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub enum External {
|
enum External {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -39,9 +41,10 @@ fn enum_external_tag() -> TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only `Struct` variant should have additionalProperties: false
|
// Only `Struct` variant should have additionalProperties: false
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "typeProperty", deny_unknown_fields)]
|
#[schemars(tag = "typeProperty", deny_unknown_fields)]
|
||||||
pub enum Internal {
|
enum Internal {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -61,9 +64,10 @@ fn enum_internal_tag() -> TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only `Struct` variant should have additionalProperties: false
|
// Only `Struct` variant should have additionalProperties: false
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(untagged, deny_unknown_fields)]
|
#[schemars(untagged, deny_unknown_fields)]
|
||||||
pub enum Untagged {
|
enum Untagged {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -83,9 +87,10 @@ fn enum_untagged() -> TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outer container and `Struct` variant should have additionalProperties: false
|
// Outer container and `Struct` variant should have additionalProperties: false
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "t", content = "c", deny_unknown_fields)]
|
#[schemars(tag = "t", content = "c", deny_unknown_fields)]
|
||||||
pub enum Adjacent {
|
enum Adjacent {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<&'static str, &'static str>),
|
StringMap(Map<&'static str, &'static str>),
|
||||||
UnitStructNewType(UnitStruct),
|
UnitStructNewType(UnitStruct),
|
||||||
|
@ -105,9 +110,10 @@ fn enum_adjacent_tagged() -> TestResult {
|
||||||
test_default_generated_schema::<Adjacent>("enum-adjacent-tagged-duf")
|
test_default_generated_schema::<Adjacent>("enum-adjacent-tagged-duf")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "typeProperty", deny_unknown_fields)]
|
#[schemars(tag = "typeProperty", deny_unknown_fields)]
|
||||||
pub enum SimpleInternal {
|
enum SimpleInternal {
|
||||||
A,
|
A,
|
||||||
B,
|
B,
|
||||||
C,
|
C,
|
||||||
|
|
|
@ -3,9 +3,9 @@ use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Default, Debug, JsonSchema, Serialize)]
|
#[derive(Default, JsonSchema, Serialize)]
|
||||||
#[schemars(example = "Struct::default", example = "null")]
|
#[schemars(example = "Struct::default", example = "null")]
|
||||||
pub struct Struct {
|
struct Struct {
|
||||||
#[schemars(example = "eight", example = "null")]
|
#[schemars(example = "eight", example = "null")]
|
||||||
foo: i32,
|
foo: i32,
|
||||||
bar: bool,
|
bar: bool,
|
||||||
|
|
|
@ -3,7 +3,8 @@ use schemars::JsonSchema;
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct OsStrings {
|
struct OsStrings {
|
||||||
owned: OsString,
|
owned: OsString,
|
||||||
borrowed: &'static OsStr,
|
borrowed: &'static OsStr,
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct Flat {
|
struct Flat {
|
||||||
f: f32,
|
f: f32,
|
||||||
b: bool,
|
b: bool,
|
||||||
|
@ -12,7 +13,8 @@ struct Flat {
|
||||||
v: Vec<i32>,
|
v: Vec<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[schemars(rename = "Flat")]
|
#[schemars(rename = "Flat")]
|
||||||
struct Deep1 {
|
struct Deep1 {
|
||||||
f: f32,
|
f: f32,
|
||||||
|
@ -21,8 +23,8 @@ struct Deep1 {
|
||||||
v: Vec<i32>,
|
v: Vec<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::option_option)]
|
#[allow(clippy::option_option, dead_code)]
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
struct Deep2 {
|
struct Deep2 {
|
||||||
b: bool,
|
b: bool,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
|
@ -31,12 +33,14 @@ struct Deep2 {
|
||||||
deep4: Box<Option<Option<Box<Deep4>>>>,
|
deep4: Box<Option<Option<Box<Deep4>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct Deep3 {
|
struct Deep3 {
|
||||||
s: &'static str,
|
s: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct Deep4 {
|
struct Deep4 {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
os: &'static str,
|
os: &'static str,
|
||||||
|
|
|
@ -3,7 +3,8 @@ use indexmap::{IndexMap, IndexSet};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct IndexMapTypes {
|
struct IndexMapTypes {
|
||||||
map: IndexMap<i32, bool>,
|
map: IndexMap<i32, bool>,
|
||||||
set: IndexSet<isize>,
|
set: IndexSet<isize>,
|
||||||
|
|
|
@ -3,14 +3,16 @@ use schemars::gen::SchemaSettings;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct MyJob {
|
#[derive(JsonSchema)]
|
||||||
pub spec: MyJobSpec,
|
struct MyJob {
|
||||||
|
spec: MyJobSpec,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct MyJobSpec {
|
#[derive(JsonSchema)]
|
||||||
pub replicas: u32,
|
struct MyJobSpec {
|
||||||
|
replicas: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -20,15 +22,17 @@ fn struct_normal() -> TestResult {
|
||||||
test_generated_schema::<MyJob>("inline-subschemas", settings)
|
test_generated_schema::<MyJob>("inline-subschemas", settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct RecursiveOuter {
|
#[derive(JsonSchema)]
|
||||||
pub direct: Option<Box<RecursiveOuter>>,
|
struct RecursiveOuter {
|
||||||
pub indirect: Option<Box<RecursiveInner>>,
|
direct: Option<Box<RecursiveOuter>>,
|
||||||
|
indirect: Option<Box<RecursiveInner>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct RecursiveInner {
|
#[derive(JsonSchema)]
|
||||||
pub recursive: RecursiveOuter,
|
struct RecursiveInner {
|
||||||
|
recursive: RecursiveOuter,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -6,7 +6,8 @@ macro_rules! build_struct {
|
||||||
(
|
(
|
||||||
$id:ident { $($t:tt)* }
|
$id:ident { $($t:tt)* }
|
||||||
) => {
|
) => {
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
pub struct $id {
|
pub struct $id {
|
||||||
x: u8,
|
x: u8,
|
||||||
$($t)*
|
$($t)*
|
||||||
|
@ -53,9 +54,9 @@ macro_rules! build_enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
build_enum!(
|
build_enum!(
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
OuterEnum {
|
OuterEnum {
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
InnerStruct {
|
InnerStruct {
|
||||||
x: i32
|
x: i32
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
unsigned: u32,
|
unsigned: u32,
|
||||||
nonzero_unsigned: std::num::NonZeroU32,
|
nonzero_unsigned: std::num::NonZeroU32,
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
camel_case: i32,
|
camel_case: i32,
|
||||||
|
|
|
@ -3,7 +3,8 @@ use schemars::JsonSchema;
|
||||||
use std::ops::{Bound, Range, RangeInclusive};
|
use std::ops::{Bound, Range, RangeInclusive};
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
range: Range<usize>,
|
range: Range<usize>,
|
||||||
inclusive: RangeInclusive<f64>,
|
inclusive: RangeInclusive<f64>,
|
||||||
|
|
|
@ -6,14 +6,14 @@ use serde::Serialize;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
mod other_crate {
|
mod other_crate {
|
||||||
#[derive(Debug, Default)]
|
#[derive(Default)]
|
||||||
pub struct Duration {
|
pub struct Duration {
|
||||||
pub secs: i64,
|
pub secs: i64,
|
||||||
pub nanos: i32,
|
pub nanos: i32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema, Serialize)]
|
#[derive(JsonSchema, Serialize)]
|
||||||
#[serde(remote = "Duration")]
|
#[serde(remote = "Duration")]
|
||||||
struct DurationDef {
|
struct DurationDef {
|
||||||
secs: i64,
|
secs: i64,
|
||||||
|
@ -27,7 +27,7 @@ where
|
||||||
ser.collect_str(&format_args!("{}.{:09}s", value.secs, value.nanos))
|
ser.collect_str(&format_args!("{}.{:09}s", value.secs, value.nanos))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema, Serialize)]
|
#[derive(JsonSchema, Serialize)]
|
||||||
struct Process {
|
struct Process {
|
||||||
command_line: String,
|
command_line: String,
|
||||||
#[serde(with = "DurationDef")]
|
#[serde(with = "DurationDef")]
|
||||||
|
|
|
@ -5,10 +5,9 @@ use serde::Serialize;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
enum Or<A, B> {
|
enum Or<A, B> {
|
||||||
#[allow(dead_code)]
|
|
||||||
A(A),
|
A(A),
|
||||||
#[allow(dead_code)]
|
|
||||||
B(B),
|
B(B),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,14 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct Container {
|
struct Container {
|
||||||
result1: Result<MyStruct, Vec<String>>,
|
result1: Result<MyStruct, Vec<String>>,
|
||||||
result2: Result<bool, ()>,
|
result2: Result<bool, ()>,
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MyStruct<T, U, V, W> {
|
struct MyStruct<T, U, V, W> {
|
||||||
t: T,
|
t: T,
|
||||||
u: U,
|
u: U,
|
||||||
|
@ -11,7 +12,8 @@ struct MyStruct<T, U, V, W> {
|
||||||
inner: MySimpleStruct,
|
inner: MySimpleStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MySimpleStruct {
|
struct MySimpleStruct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
}
|
}
|
||||||
|
@ -21,7 +23,8 @@ fn default_name_multiple_type_params() -> TestResult {
|
||||||
test_default_generated_schema::<MyStruct<i32, (), bool, Vec<String>>>("schema-name-default")
|
test_default_generated_schema::<MyStruct<i32, (), bool, Vec<String>>>("schema-name-default")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[serde(rename = "a-new-name-{W}-{T}-{T}")]
|
#[serde(rename = "a-new-name-{W}-{T}-{T}")]
|
||||||
#[schemars(rename_all = "camelCase")]
|
#[schemars(rename_all = "camelCase")]
|
||||||
struct MyRenamedStruct<T, U, V, W> {
|
struct MyRenamedStruct<T, U, V, W> {
|
||||||
|
@ -32,7 +35,8 @@ struct MyRenamedStruct<T, U, V, W> {
|
||||||
inner: MySimpleRenamedStruct,
|
inner: MySimpleRenamedStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[serde(rename = "this-attribute-is-ignored")]
|
#[serde(rename = "this-attribute-is-ignored")]
|
||||||
#[schemars(rename = "another-new-name")]
|
#[schemars(rename = "another-new-name")]
|
||||||
struct MySimpleRenamedStruct {
|
struct MySimpleRenamedStruct {
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn schema_fn(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Sche
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DoesntImplementJsonSchema;
|
pub struct DoesntImplementJsonSchema;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(rename_all = "camelCase")]
|
#[schemars(rename_all = "camelCase")]
|
||||||
pub enum External {
|
pub enum External {
|
||||||
Struct {
|
Struct {
|
||||||
|
@ -30,7 +30,7 @@ fn enum_external_tag() -> TestResult {
|
||||||
test_default_generated_schema::<External>("schema_with-enum-external")
|
test_default_generated_schema::<External>("schema_with-enum-external")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "typeProperty")]
|
#[schemars(tag = "typeProperty")]
|
||||||
pub enum Internal {
|
pub enum Internal {
|
||||||
Struct {
|
Struct {
|
||||||
|
@ -47,7 +47,7 @@ fn enum_internal_tag() -> TestResult {
|
||||||
test_default_generated_schema::<Internal>("schema_with-enum-internal")
|
test_default_generated_schema::<Internal>("schema_with-enum-internal")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(untagged)]
|
#[schemars(untagged)]
|
||||||
pub enum Untagged {
|
pub enum Untagged {
|
||||||
Struct {
|
Struct {
|
||||||
|
@ -68,7 +68,7 @@ fn enum_untagged() -> TestResult {
|
||||||
test_default_generated_schema::<Untagged>("schema_with-enum-untagged")
|
test_default_generated_schema::<Untagged>("schema_with-enum-untagged")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(tag = "t", content = "c")]
|
#[schemars(tag = "t", content = "c")]
|
||||||
pub enum Adjacent {
|
pub enum Adjacent {
|
||||||
Struct {
|
Struct {
|
||||||
|
|
|
@ -6,11 +6,11 @@ fn schema_fn(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Sche
|
||||||
<bool>::json_schema(gen)
|
<bool>::json_schema(gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct DoesntImplementJsonSchema;
|
struct DoesntImplementJsonSchema;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct Struct {
|
#[derive(JsonSchema)]
|
||||||
|
struct Struct {
|
||||||
#[schemars(schema_with = "schema_fn")]
|
#[schemars(schema_with = "schema_fn")]
|
||||||
foo: DoesntImplementJsonSchema,
|
foo: DoesntImplementJsonSchema,
|
||||||
bar: i32,
|
bar: i32,
|
||||||
|
@ -23,7 +23,7 @@ fn struct_normal() -> TestResult {
|
||||||
test_default_generated_schema::<Struct>("schema_with-struct")
|
test_default_generated_schema::<Struct>("schema_with-struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct Tuple(
|
pub struct Tuple(
|
||||||
#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema,
|
#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema,
|
||||||
i32,
|
i32,
|
||||||
|
@ -35,7 +35,7 @@ fn struct_tuple() -> TestResult {
|
||||||
test_default_generated_schema::<Tuple>("schema_with-tuple")
|
test_default_generated_schema::<Tuple>("schema_with-tuple")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct Newtype(#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema);
|
pub struct Newtype(#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -43,7 +43,7 @@ fn struct_newtype() -> TestResult {
|
||||||
test_default_generated_schema::<Newtype>("schema_with-newtype")
|
test_default_generated_schema::<Newtype>("schema_with-newtype")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(transparent)]
|
#[schemars(transparent)]
|
||||||
pub struct TransparentNewtype(#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema);
|
pub struct TransparentNewtype(#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
#[schemars(skip)]
|
#[schemars(skip)]
|
||||||
skipped1: i32,
|
skipped1: i32,
|
||||||
|
@ -20,7 +21,7 @@ fn skip_struct_fields() -> TestResult {
|
||||||
test_default_generated_schema::<MyStruct>("skip_struct_fields")
|
test_default_generated_schema::<MyStruct>("skip_struct_fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
struct TupleStruct(
|
struct TupleStruct(
|
||||||
#[schemars(skip)] i32,
|
#[schemars(skip)] i32,
|
||||||
#[serde(skip)] bool,
|
#[serde(skip)] bool,
|
||||||
|
@ -34,7 +35,7 @@ fn skip_tuple_fields() -> TestResult {
|
||||||
test_default_generated_schema::<TupleStruct>("skip_tuple_fields")
|
test_default_generated_schema::<TupleStruct>("skip_tuple_fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub enum MyEnum {
|
pub enum MyEnum {
|
||||||
#[schemars(skip)]
|
#[schemars(skip)]
|
||||||
Skipped1(i32),
|
Skipped1(i32),
|
||||||
|
|
|
@ -5,8 +5,9 @@ use util::*;
|
||||||
// Ensure that schemars_derive uses the full path to std::string::String
|
// Ensure that schemars_derive uses the full path to std::string::String
|
||||||
pub struct String;
|
pub struct String;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
pub struct Struct {
|
#[derive(JsonSchema)]
|
||||||
|
struct Struct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
bar: bool,
|
bar: bool,
|
||||||
baz: Option<&'static str>,
|
baz: Option<&'static str>,
|
||||||
|
@ -17,7 +18,7 @@ fn struct_normal() -> TestResult {
|
||||||
test_default_generated_schema::<Struct>("struct-normal")
|
test_default_generated_schema::<Struct>("struct-normal")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct Tuple(i32, bool, Option<&'static str>);
|
pub struct Tuple(i32, bool, Option<&'static str>);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -25,7 +26,7 @@ fn struct_tuple() -> TestResult {
|
||||||
test_default_generated_schema::<Tuple>("struct-tuple")
|
test_default_generated_schema::<Tuple>("struct-tuple")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct Newtype(i32);
|
pub struct Newtype(i32);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -33,7 +34,7 @@ fn struct_newtype() -> TestResult {
|
||||||
test_default_generated_schema::<Newtype>("struct-newtype")
|
test_default_generated_schema::<Newtype>("struct-newtype")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct Unit;
|
pub struct Unit;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -2,7 +2,8 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Struct {
|
pub struct Struct {
|
||||||
foo: i32,
|
foo: i32,
|
||||||
|
|
|
@ -3,7 +3,8 @@ use schemars::JsonSchema;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
duration: Duration,
|
duration: Duration,
|
||||||
time: SystemTime,
|
time: SystemTime,
|
||||||
|
|
|
@ -2,23 +2,25 @@ mod util;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
pub struct OuterStruct {
|
pub struct OuterStruct {
|
||||||
inner: TransparentStruct,
|
inner: TransparentStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct TransparentStruct {
|
pub struct TransparentStruct {
|
||||||
#[serde(with = "TransparentNewType")]
|
#[serde(with = "TransparentNewType")]
|
||||||
inner: (),
|
inner: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
#[schemars(transparent)]
|
#[schemars(transparent)]
|
||||||
pub struct TransparentNewType(Option<InnerStruct>);
|
pub struct TransparentNewType(Option<InnerStruct>);
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct InnerStruct(String, i32);
|
pub struct InnerStruct(String, i32);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -3,7 +3,8 @@ use schemars::JsonSchema;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
struct UrlTypes {
|
struct UrlTypes {
|
||||||
url: Url,
|
url: Url,
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ static STARTS_WITH_HELLO: &'static str = r"^[Hh]ello\b";
|
||||||
const MIN: u32 = 1;
|
const MIN: u32 = 1;
|
||||||
const MAX: u32 = 1000;
|
const MAX: u32 = 1000;
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
pub struct Struct {
|
pub struct Struct {
|
||||||
#[validate(range(min = 0.01, max = 100))]
|
#[validate(range(min = 0.01, max = 100))]
|
||||||
min_max: f32,
|
min_max: f32,
|
||||||
|
@ -47,7 +48,8 @@ pub struct Struct {
|
||||||
required_flattened: Option<Inner>,
|
required_flattened: Option<Inner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
pub struct Inner {
|
pub struct Inner {
|
||||||
x: i32,
|
x: i32,
|
||||||
}
|
}
|
||||||
|
@ -57,7 +59,8 @@ fn validate() -> TestResult {
|
||||||
test_default_generated_schema::<Struct>("validate")
|
test_default_generated_schema::<Struct>("validate")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
pub struct Struct2 {
|
pub struct Struct2 {
|
||||||
#[schemars(range(min = 0.01, max = 100))]
|
#[schemars(range(min = 0.01, max = 100))]
|
||||||
min_max: f32,
|
min_max: f32,
|
||||||
|
@ -101,7 +104,7 @@ fn validate_schemars_attrs() -> TestResult {
|
||||||
test_default_generated_schema::<Struct>("validate_schemars_attrs")
|
test_default_generated_schema::<Struct>("validate_schemars_attrs")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct Tuple(
|
pub struct Tuple(
|
||||||
#[validate(range(max = 10))] u8,
|
#[validate(range(max = 10))] u8,
|
||||||
#[validate(required)] Option<bool>,
|
#[validate(required)] Option<bool>,
|
||||||
|
@ -112,7 +115,7 @@ fn validate_tuple() -> TestResult {
|
||||||
test_default_generated_schema::<Tuple>("validate_tuple")
|
test_default_generated_schema::<Tuple>("validate_tuple")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(JsonSchema)]
|
||||||
pub struct NewType(#[validate(range(max = 10))] u8);
|
pub struct NewType(#[validate(range(max = 10))] u8);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue