Fix #[schemars(with = ...)] alongside #[serde(transparent)] (#67)

Co-authored-by: Graham Esau <gesau@hotmail.co.uk>
This commit is contained in:
David Hotham 2021-03-21 13:56:24 +00:00 committed by GitHub
parent 1c9ecafd32
commit c4ef7bad22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 26 deletions

View file

@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "schema_fn",
"type": "boolean"
}

View file

@ -42,3 +42,12 @@ pub struct Newtype(#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSch
fn struct_newtype() -> TestResult {
test_default_generated_schema::<Newtype>("schema_with-newtype")
}
#[derive(Debug, JsonSchema)]
#[schemars(transparent)]
pub struct TransparentNewtype(#[schemars(schema_with = "schema_fn")] DoesntImplementJsonSchema);
#[test]
fn struct_transparent_newtype() -> TestResult {
test_default_generated_schema::<TransparentNewtype>("schema_with-transparent-newtype")
}