Implement JsonSchema for OsStr/OsString
This commit is contained in:
parent
e6c178117c
commit
c6a20764fe
6 changed files with 118 additions and 9 deletions
53
schemars/tests/expected/os_strings.json
Normal file
53
schemars/tests/expected/os_strings.json
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "OsStrings",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"borrowed",
|
||||
"owned"
|
||||
],
|
||||
"properties": {
|
||||
"borrowed": {
|
||||
"$ref": "#/definitions/OS_String"
|
||||
},
|
||||
"owned": {
|
||||
"$ref": "#/definitions/OS_String"
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"OS_String": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Unix"
|
||||
],
|
||||
"properties": {
|
||||
"Unix": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint8"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Windows"
|
||||
],
|
||||
"properties": {
|
||||
"Windows": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint16"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Result_Of_MyStruct_Or_Array_Of_String",
|
||||
"type": "object",
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
15
schemars/tests/os.rs
Normal file
15
schemars/tests/os.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
mod util;
|
||||
use schemars::JsonSchema;
|
||||
use util::*;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
struct OsStrings {
|
||||
owned: OsString,
|
||||
borrowed: &'static OsStr,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn os_strings() -> TestResult {
|
||||
test_default_generated_schema::<OsStrings>("os_strings")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue