Fix deriving JsonSchema inside macro (#79)
This commit is contained in:
parent
dada8582ee
commit
4d3400152e
4 changed files with 71 additions and 21 deletions
20
schemars/tests/expected/macro_built_struct.json
Normal file
20
schemars/tests/expected/macro_built_struct.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "A",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"v",
|
||||
"x"
|
||||
],
|
||||
"properties": {
|
||||
"x": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
},
|
||||
"v": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
22
schemars/tests/macro.rs
Normal file
22
schemars/tests/macro.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
mod util;
|
||||
use schemars::JsonSchema;
|
||||
use util::*;
|
||||
|
||||
macro_rules! build_struct {
|
||||
(
|
||||
$id:ident { $($t:tt)* }
|
||||
) => {
|
||||
#[derive(Debug, JsonSchema)]
|
||||
pub struct $id {
|
||||
x: u8,
|
||||
$($t)*
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
build_struct!(A { v: i32 });
|
||||
|
||||
#[test]
|
||||
fn macro_built_struct() -> TestResult {
|
||||
test_default_generated_schema::<A>("macro_built_struct")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue