Add #[schemars(inner(...)] attribute to specify schema for array items (#234)
This commit is contained in:
parent
30e513ac14
commit
a5e51b22b3
11 changed files with 231 additions and 60 deletions
|
@ -10,6 +10,8 @@ pub struct MyStruct {
|
|||
pub my_bool: bool,
|
||||
#[schemars(default)]
|
||||
pub my_nullable_enum: Option<MyEnum>,
|
||||
#[schemars(inner(regex(pattern = "^x$")))]
|
||||
pub my_vec_str: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, JsonSchema)]
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"type": "object",
|
||||
"required": [
|
||||
"myBool",
|
||||
"myNumber"
|
||||
"myNumber",
|
||||
"myVecStr"
|
||||
],
|
||||
"properties": {
|
||||
"myBool": {
|
||||
|
@ -26,6 +27,13 @@
|
|||
"format": "int32",
|
||||
"maximum": 10.0,
|
||||
"minimum": 1.0
|
||||
},
|
||||
"myVecStr": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^x$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue