Implement JsonSchema for OsStr/OsString

This commit is contained in:
Graham Esau 2019-10-27 19:26:17 +00:00
parent e6c178117c
commit c6a20764fe
6 changed files with 118 additions and 9 deletions

View 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"
}
}
}
}
]
}
}
}

View file

@ -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
View 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")
}