Re-add preserve_order feature, to preserve order of struct fields in a schema's properties

This commit is contained in:
Graham Esau 2024-05-18 21:55:05 +01:00
parent c4d42ec11a
commit d3b6ff5aeb
60 changed files with 757 additions and 773 deletions

1
Cargo.lock generated
View file

@ -381,6 +381,7 @@ version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
dependencies = [ dependencies = [
"indexmap",
"itoa", "itoa",
"ryu", "ryu",
"serde", "serde",

View file

@ -44,6 +44,7 @@ serde = { version = "1.0", features = ["derive"] }
default = ["derive"] default = ["derive"]
derive = ["schemars_derive"] derive = ["schemars_derive"]
preserve_order = ["serde_json/preserve_order"]
raw_value = ["serde_json/raw_value"] raw_value = ["serde_json/raw_value"]

View file

@ -11,8 +11,9 @@ use crate::Schema;
use crate::{visit::*, JsonSchema}; use crate::{visit::*, JsonSchema};
use dyn_clone::DynClone; use dyn_clone::DynClone;
use serde::Serialize; use serde::Serialize;
use serde_json::{Map, Value};
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::{BTreeMap, HashMap}; use std::collections::HashMap;
use std::{any::Any, collections::HashSet, fmt::Debug}; use std::{any::Any, collections::HashSet, fmt::Debug};
/// Settings to customize how Schemas are generated. /// Settings to customize how Schemas are generated.
@ -149,7 +150,7 @@ impl SchemaSettings {
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct SchemaGenerator { pub struct SchemaGenerator {
settings: SchemaSettings, settings: SchemaSettings,
definitions: BTreeMap<String, Schema>, definitions: Map<String, Value>,
pending_schema_ids: HashSet<Cow<'static, str>>, pending_schema_ids: HashSet<Cow<'static, str>>,
schema_id_to_name: HashMap<Cow<'static, str>, String>, schema_id_to_name: HashMap<Cow<'static, str>, String>,
used_schema_names: HashSet<String>, used_schema_names: HashSet<String>,
@ -254,31 +255,31 @@ impl SchemaGenerator {
let schema = self.json_schema_internal::<T>(id); let schema = self.json_schema_internal::<T>(id);
self.definitions.insert(name, schema); self.definitions.insert(name, schema.to_value());
} }
/// Borrows the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated. /// Borrows the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated.
/// ///
/// The keys of the returned `BTreeMap` are the [schema names](JsonSchema::schema_name), and the values are the schemas /// The keys of the returned `Map` are the [schema names](JsonSchema::schema_name), and the values are the schemas
/// themselves. /// themselves.
pub fn definitions(&self) -> &BTreeMap<String, Schema> { pub fn definitions(&self) -> &Map<String, Value> {
&self.definitions &self.definitions
} }
/// Mutably borrows the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated. /// Mutably borrows the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated.
/// ///
/// The keys of the returned `BTreeMap` are the [schema names](JsonSchema::schema_name), and the values are the schemas /// The keys of the returned `Map` are the [schema names](JsonSchema::schema_name), and the values are the schemas
/// themselves. /// themselves.
pub fn definitions_mut(&mut self) -> &mut BTreeMap<String, Schema> { pub fn definitions_mut(&mut self) -> &mut Map<String, Value> {
&mut self.definitions &mut self.definitions
} }
/// Returns the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated, /// Returns the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated,
/// leaving an empty map in its place. /// leaving an empty map in its place.
/// ///
/// The keys of the returned `BTreeMap` are the [schema names](JsonSchema::schema_name), and the values are the schemas /// The keys of the returned `Map` are the [schema names](JsonSchema::schema_name), and the values are the schemas
/// themselves. /// themselves.
pub fn take_definitions(&mut self) -> BTreeMap<String, Schema> { pub fn take_definitions(&mut self) -> Map<String, Value> {
std::mem::take(&mut self.definitions) std::mem::take(&mut self.definitions)
} }
@ -308,12 +309,7 @@ impl SchemaGenerator {
if !self.definitions.is_empty() { if !self.definitions.is_empty() {
object.insert( object.insert(
"definitions".into(), "definitions".into(),
serde_json::Value::Object( serde_json::Value::Object(self.definitions.clone()),
self.definitions
.iter()
.map(|(k, v)| (k.clone(), v.clone().into()))
.collect(),
),
); );
} }
@ -344,12 +340,7 @@ impl SchemaGenerator {
if !self.definitions.is_empty() { if !self.definitions.is_empty() {
object.insert( object.insert(
"definitions".into(), "definitions".into(),
serde_json::Value::Object( serde_json::Value::Object(self.definitions),
self.definitions
.into_iter()
.map(|(k, v)| (k, v.into()))
.collect(),
),
); );
} }
@ -386,12 +377,7 @@ impl SchemaGenerator {
if !self.definitions.is_empty() { if !self.definitions.is_empty() {
object.insert( object.insert(
"definitions".into(), "definitions".into(),
serde_json::Value::Object( serde_json::Value::Object(self.definitions.clone()),
self.definitions
.iter()
.map(|(k, v)| (k.clone(), v.clone().into()))
.collect(),
),
); );
} }
@ -428,12 +414,7 @@ impl SchemaGenerator {
if !self.definitions.is_empty() { if !self.definitions.is_empty() {
object.insert( object.insert(
"definitions".into(), "definitions".into(),
serde_json::Value::Object( serde_json::Value::Object(self.definitions),
self.definitions
.into_iter()
.map(|(k, v)| (k, v.into()))
.collect(),
),
); );
} }

View file

@ -180,7 +180,8 @@ mod ser {
use serde_json::Value; use serde_json::Value;
// The order of properties in a JSON Schema object is insignificant, but we explicitly order // The order of properties in a JSON Schema object is insignificant, but we explicitly order
// some of them here to make them easier for a human to read. // some of them here to make them easier for a human to read. All other properties are ordered
// either lexicographically (by default) or by insertion order (if `preserve_order` is enabled)
const ORDERED_KEYWORDS_START: [&str; 7] = [ const ORDERED_KEYWORDS_START: [&str; 7] = [
"$id", "$id",
"$schema", "$schema",

View file

@ -20,6 +20,6 @@
} }
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }

View file

@ -3,6 +3,18 @@
"title": "ChronoTypes", "title": "ChronoTypes",
"type": "object", "type": "object",
"properties": { "properties": {
"weekday": {
"type": "string",
"enum": [
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
]
},
"date_time": { "date_time": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -18,18 +30,6 @@
"naive_time": { "naive_time": {
"type": "string", "type": "string",
"format": "partial-date-time" "format": "partial-date-time"
},
"weekday": {
"type": "string",
"enum": [
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
]
} }
}, },
"required": [ "required": [

View file

@ -3,13 +3,13 @@
"title": "Struct", "title": "Struct",
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"description": "This is a document", "description": "This is a document",
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [

View file

@ -3,22 +3,22 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"my_bool": {
"type": "boolean",
"default": false
},
"my_int": { "my_int": {
"type": "integer", "type": "integer",
"format": "int32", "format": "int32",
"default": 0 "default": 0
}, },
"my_bool": {
"type": "boolean",
"default": false
},
"my_struct2": { "my_struct2": {
"default": "i:0 b:false",
"allOf": [ "allOf": [
{ {
"$ref": "#/definitions/MyStruct2" "$ref": "#/definitions/MyStruct2"
} }
], ]
"default": "i:0 b:false"
}, },
"my_struct2_default_skipped": { "my_struct2_default_skipped": {
"$ref": "#/definitions/MyStruct2" "$ref": "#/definitions/MyStruct2"
@ -31,14 +31,14 @@
"MyStruct2": { "MyStruct2": {
"type": "object", "type": "object",
"properties": { "properties": {
"my_bool": {
"type": "boolean",
"default": true
},
"my_int": { "my_int": {
"type": "integer", "type": "integer",
"format": "int32", "format": "int32",
"default": 6 "default": 6
},
"my_bool": {
"type": "boolean",
"default": true
} }
} }
}, },

View file

@ -1,7 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "DeprecatedEnum", "title": "DeprecatedEnum",
"deprecated": true,
"oneOf": [ "oneOf": [
{ {
"type": "string", "type": "string",
@ -20,13 +19,13 @@
"DeprecatedStructVariant": { "DeprecatedStructVariant": {
"type": "object", "type": "object",
"properties": { "properties": {
"deprecated_field": {
"type": "boolean",
"deprecated": true
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"deprecated_field": {
"type": "boolean",
"deprecated": true
} }
}, },
"required": [ "required": [
@ -35,11 +34,12 @@
] ]
} }
}, },
"additionalProperties": false,
"deprecated": true,
"required": [ "required": [
"DeprecatedStructVariant" "DeprecatedStructVariant"
] ],
"additionalProperties": false,
"deprecated": true
} }
] ],
"deprecated": true
} }

View file

@ -3,18 +3,18 @@
"title": "DeprecatedStruct", "title": "DeprecatedStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"deprecated_field": {
"type": "boolean",
"deprecated": true
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"deprecated_field": {
"type": "boolean",
"deprecated": true
} }
}, },
"deprecated": true,
"required": [ "required": [
"foo", "foo",
"deprecated_field" "deprecated_field"
] ],
"deprecated": true
} }

View file

@ -34,10 +34,10 @@
} }
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"Complex" "Complex"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -18,15 +18,15 @@
"Duration": { "Duration": {
"type": "object", "type": "object",
"properties": { "properties": {
"nanos": {
"type": "integer",
"format": "uint32",
"minimum": 0
},
"secs": { "secs": {
"type": "integer", "type": "integer",
"format": "uint64", "format": "uint64",
"minimum": 0 "minimum": 0
},
"nanos": {
"type": "integer",
"format": "uint32",
"minimum": 0
} }
}, },
"required": [ "required": [
@ -37,15 +37,15 @@
"SystemTime": { "SystemTime": {
"type": "object", "type": "object",
"properties": { "properties": {
"nanos_since_epoch": {
"type": "integer",
"format": "uint32",
"minimum": 0
},
"secs_since_epoch": { "secs_since_epoch": {
"type": "integer", "type": "integer",
"format": "uint64", "format": "uint64",
"minimum": 0 "minimum": 0
},
"nanos_since_epoch": {
"type": "integer",
"format": "uint32",
"minimum": 0
} }
}, },
"required": [ "required": [

View file

@ -12,83 +12,89 @@
] ]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t" "t"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"StringMap" "StringMap"
] ]
},
"c": {
"type": "object",
"additionalProperties": {
"type": "string"
}
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t", "t",
"c" "c"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"$ref": "#/definitions/UnitStruct"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"UnitStructNewType" "UnitStructNewType"
] ]
},
"c": {
"$ref": "#/definitions/UnitStruct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t", "t",
"c" "c"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"$ref": "#/definitions/Struct"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"StructNewType" "StructNewType"
] ]
},
"c": {
"$ref": "#/definitions/Struct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t", "t",
"c" "c"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"t": {
"type": "string",
"enum": [
"Struct"
]
},
"c": { "c": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -96,23 +102,23 @@
"foo", "foo",
"bar" "bar"
] ]
},
"t": {
"type": "string",
"enum": [
"Struct"
]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t", "t",
"c" "c"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"t": {
"type": "string",
"enum": [
"Tuple"
]
},
"c": { "c": {
"type": "array", "type": "array",
"items": [ "items": [
@ -124,21 +130,15 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
},
"t": {
"type": "string",
"enum": [
"Tuple"
]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t", "t",
"c" "c"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -150,51 +150,51 @@
] ]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t" "t"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"type": "integer",
"format": "int32"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"WithInt" "WithInt"
] ]
},
"c": {
"type": "integer",
"format": "int32"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"t", "t",
"c" "c"
] ],
"additionalProperties": false
} }
], ],
"definitions": { "definitions": {
"UnitStruct": {
"type": "null"
},
"Struct": { "Struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"UnitStruct": {
"type": "null"
} }
} }
} }

View file

@ -19,17 +19,17 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"StringMap" "StringMap"
] ]
},
"c": {
"type": "object",
"additionalProperties": {
"type": "string"
}
} }
}, },
"required": [ "required": [
@ -40,14 +40,14 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"$ref": "#/definitions/UnitStruct"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"UnitStructNewType" "UnitStructNewType"
] ]
},
"c": {
"$ref": "#/definitions/UnitStruct"
} }
}, },
"required": [ "required": [
@ -58,14 +58,14 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"$ref": "#/definitions/Struct"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"StructNewType" "StructNewType"
] ]
},
"c": {
"$ref": "#/definitions/Struct"
} }
}, },
"required": [ "required": [
@ -76,27 +76,27 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"t": {
"type": "string",
"enum": [
"Struct"
]
},
"c": { "c": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"t": {
"type": "string",
"enum": [
"Struct"
]
} }
}, },
"required": [ "required": [
@ -107,6 +107,12 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"t": {
"type": "string",
"enum": [
"Tuple"
]
},
"c": { "c": {
"type": "array", "type": "array",
"items": [ "items": [
@ -118,14 +124,8 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
},
"t": {
"type": "string",
"enum": [
"Tuple"
]
} }
}, },
"required": [ "required": [
@ -150,15 +150,15 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"type": "integer",
"format": "int32"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"WithInt" "WithInt"
] ]
},
"c": {
"type": "integer",
"format": "int32"
} }
}, },
"required": [ "required": [
@ -168,24 +168,24 @@
} }
], ],
"definitions": { "definitions": {
"UnitStruct": {
"type": "null"
},
"Struct": { "Struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"UnitStruct": {
"type": "null"
} }
} }
} }

View file

@ -19,10 +19,10 @@
} }
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"stringMap" "stringMap"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -31,10 +31,10 @@
"$ref": "#/definitions/UnitStruct" "$ref": "#/definitions/UnitStruct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"unitStructNewType" "unitStructNewType"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -43,10 +43,10 @@
"$ref": "#/definitions/Struct" "$ref": "#/definitions/Struct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"structNewType" "structNewType"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -54,12 +54,12 @@
"struct": { "struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -69,10 +69,10 @@
] ]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"struct" "struct"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -88,14 +88,14 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"tuple" "tuple"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -105,31 +105,31 @@
"format": "int32" "format": "int32"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"withInt" "withInt"
] ],
"additionalProperties": false
} }
], ],
"definitions": { "definitions": {
"UnitStruct": {
"type": "null"
},
"Struct": { "Struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"UnitStruct": {
"type": "null"
} }
} }
} }

View file

@ -19,10 +19,10 @@
} }
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"stringMap" "stringMap"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -31,10 +31,10 @@
"$ref": "#/definitions/UnitStruct" "$ref": "#/definitions/UnitStruct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"unitStructNewType" "unitStructNewType"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -43,10 +43,10 @@
"$ref": "#/definitions/Struct" "$ref": "#/definitions/Struct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"structNewType" "structNewType"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -54,12 +54,12 @@
"struct": { "struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
@ -68,10 +68,10 @@
] ]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"struct" "struct"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -87,14 +87,14 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"tuple" "tuple"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -104,31 +104,31 @@
"format": "int32" "format": "int32"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"withInt" "withInt"
] ],
"additionalProperties": false
} }
], ],
"definitions": { "definitions": {
"UnitStruct": {
"type": "null"
},
"Struct": { "Struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"UnitStruct": {
"type": "null"
} }
} }
} }

View file

@ -10,10 +10,10 @@
"const": "UnitOne" "const": "UnitOne"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"typeProperty" "typeProperty"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -38,21 +38,21 @@
"const": "UnitStructNewType" "const": "UnitStructNewType"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"typeProperty" "typeProperty"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"bar": {
"type": "boolean"
},
"typeProperty": { "typeProperty": {
"type": "string", "type": "string",
"const": "StructNewType" "const": "StructNewType"
@ -67,13 +67,13 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"bar": {
"type": "boolean"
},
"typeProperty": { "typeProperty": {
"type": "string", "type": "string",
"const": "Struct" "const": "Struct"
@ -94,10 +94,10 @@
"const": "UnitTwo" "const": "UnitTwo"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"typeProperty" "typeProperty"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",

View file

@ -44,13 +44,13 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"bar": {
"type": "boolean"
},
"typeProperty": { "typeProperty": {
"type": "string", "type": "string",
"const": "StructNewType" "const": "StructNewType"
@ -65,13 +65,13 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"bar": {
"type": "boolean"
},
"typeProperty": { "typeProperty": {
"type": "string", "type": "string",
"const": "Struct" "const": "Struct"

View file

@ -10,10 +10,10 @@
"const": "A" "const": "A"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"typeProperty" "typeProperty"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -23,10 +23,10 @@
"const": "B" "const": "B"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"typeProperty" "typeProperty"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -36,10 +36,10 @@
"const": "C" "const": "C"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"typeProperty" "typeProperty"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -20,12 +20,12 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -45,8 +45,8 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
}, },
{ {
"type": "integer", "type": "integer",
@ -54,24 +54,24 @@
} }
], ],
"definitions": { "definitions": {
"UnitStruct": {
"type": "null"
},
"Struct": { "Struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"UnitStruct": {
"type": "null"
} }
} }
} }

View file

@ -20,12 +20,12 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
@ -44,8 +44,8 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
}, },
{ {
"type": "integer", "type": "integer",
@ -53,24 +53,24 @@
} }
], ],
"definitions": { "definitions": {
"UnitStruct": {
"type": "null"
},
"Struct": { "Struct": {
"type": "object", "type": "object",
"properties": { "properties": {
"bar": {
"type": "boolean"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"bar": {
"type": "boolean"
} }
}, },
"required": [ "required": [
"foo", "foo",
"bar" "bar"
] ]
},
"UnitStruct": {
"type": "null"
} }
} }
} }

View file

@ -2,10 +2,10 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "Set_of_Foo", "title": "Set_of_Foo",
"type": "array", "type": "array",
"uniqueItems": true,
"items": { "items": {
"$ref": "#/definitions/Foo" "$ref": "#/definitions/Foo"
}, },
"uniqueItems": true,
"definitions": { "definitions": {
"Foo": { "Foo": {
"type": "string", "type": "string",

View file

@ -3,6 +3,14 @@
"title": "Struct", "title": "Struct",
"type": "object", "type": "object",
"properties": { "properties": {
"foo": {
"type": "integer",
"format": "int32",
"examples": [
8,
null
]
},
"bar": { "bar": {
"type": "boolean" "type": "boolean"
}, },
@ -14,26 +22,18 @@
"examples": [ "examples": [
null null
] ]
},
"foo": {
"type": "integer",
"format": "int32",
"examples": [
8,
null
]
} }
}, },
"examples": [
{
"bar": false,
"baz": null,
"foo": 0
},
null
],
"required": [ "required": [
"foo", "foo",
"bar" "bar"
],
"examples": [
{
"foo": 0,
"bar": false,
"baz": null
},
null
] ]
} }

View file

@ -3,20 +3,20 @@
"title": "Flat", "title": "Flat",
"type": "object", "type": "object",
"properties": { "properties": {
"b": {
"type": "boolean"
},
"f": { "f": {
"type": "number", "type": "number",
"format": "float" "format": "float"
}, },
"os": { "b": {
"type": "string", "type": "boolean"
"default": ""
}, },
"s": { "s": {
"type": "string" "type": "string"
}, },
"os": {
"type": "string",
"default": ""
},
"v": { "v": {
"type": "array", "type": "array",
"items": { "items": {

View file

@ -2,12 +2,21 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"type": "object", "type": "object",
"properties": { "properties": {
"bool": { "zero": {
"type": "boolean" "type": "integer"
},
"one": {
"type": "integer"
}, },
"minusOne": { "minusOne": {
"type": "integer" "type": "integer"
}, },
"zeroPointZero": {
"type": "number"
},
"bool": {
"type": "boolean"
},
"null": true, "null": true,
"object": { "object": {
"type": "object", "type": "object",
@ -19,31 +28,22 @@
} }
} }
} }
},
"one": {
"type": "integer"
},
"zero": {
"type": "integer"
},
"zeroPointZero": {
"type": "number"
} }
}, },
"examples": [ "examples": [
{ {
"bool": true, "zero": 0,
"one": 1,
"minusOne": -1, "minusOne": -1,
"zeroPointZero": 0.0,
"bool": true,
"null": null, "null": null,
"object": { "object": {
"array": [ "array": [
"foo", "foo",
"bar" "bar"
] ]
}, }
"one": 1,
"zero": 0,
"zeroPointZero": 0.0
} }
] ]
} }

View file

@ -3,12 +3,28 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"myInt": {
"type": "integer"
},
"myBool": { "myBool": {
"type": "boolean" "type": "boolean"
}, },
"myNullableEnum": true,
"myInnerStruct": { "myInnerStruct": {
"type": "object", "type": "object",
"properties": { "properties": {
"my_map": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"my_vec": {
"type": "array",
"items": {
"type": "string"
}
},
"my_empty_map": { "my_empty_map": {
"type": "object", "type": "object",
"additionalProperties": true "additionalProperties": true
@ -17,19 +33,13 @@
"type": "array", "type": "array",
"items": true "items": true
}, },
"my_map": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"my_tuple": { "my_tuple": {
"type": "array", "type": "array",
"items": [ "items": [
{ {
"type": "string", "type": "string",
"maxLength": 1, "minLength": 1,
"minLength": 1 "maxLength": 1
}, },
{ {
"type": "integer" "type": "integer"
@ -37,40 +47,30 @@
], ],
"maxItems": 2, "maxItems": 2,
"minItems": 2 "minItems": 2
},
"my_vec": {
"type": "array",
"items": {
"type": "string"
}
} }
} }
}, }
"myInt": {
"type": "integer"
},
"myNullableEnum": true
}, },
"examples": [ "examples": [
{ {
"myInt": 123,
"myBool": true, "myBool": true,
"myNullableEnum": null,
"myInnerStruct": { "myInnerStruct": {
"my_empty_map": {},
"my_empty_vec": [],
"my_map": { "my_map": {
"": 0.0 "": 0.0
}, },
"my_tuple": [
"💩",
42
],
"my_vec": [ "my_vec": [
"hello", "hello",
"world" "world"
],
"my_empty_map": {},
"my_empty_vec": [],
"my_tuple": [
"💩",
42
] ]
}, }
"myInt": 123,
"myNullableEnum": null
} }
] ]
} }

View file

@ -3,12 +3,28 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"myInt": {
"type": "integer"
},
"myBool": { "myBool": {
"type": "boolean" "type": "boolean"
}, },
"myNullableEnum": true,
"myInnerStruct": { "myInnerStruct": {
"type": "object", "type": "object",
"properties": { "properties": {
"my_map": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"my_vec": {
"type": "array",
"items": {
"type": "string"
}
},
"my_empty_map": { "my_empty_map": {
"type": "object", "type": "object",
"additionalProperties": true "additionalProperties": true
@ -17,19 +33,13 @@
"type": "array", "type": "array",
"items": true "items": true
}, },
"my_map": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"my_tuple": { "my_tuple": {
"type": "array", "type": "array",
"items": [ "items": [
{ {
"type": "string", "type": "string",
"maxLength": 1, "minLength": 1,
"minLength": 1 "maxLength": 1
}, },
{ {
"type": "integer" "type": "integer"
@ -37,40 +47,30 @@
], ],
"maxItems": 2, "maxItems": 2,
"minItems": 2 "minItems": 2
},
"my_vec": {
"type": "array",
"items": {
"type": "string"
}
} }
} }
}, }
"myInt": {
"type": "integer"
},
"myNullableEnum": true
}, },
"examples": [ "examples": [
{ {
"myInt": 123,
"myBool": true, "myBool": true,
"myNullableEnum": null,
"myInnerStruct": { "myInnerStruct": {
"my_empty_map": {},
"my_empty_vec": [],
"my_map": { "my_map": {
"": 0.0 "": 0.0
}, },
"my_tuple": [
"💩",
42
],
"my_vec": [ "my_vec": [
"hello", "hello",
"world" "world"
],
"my_empty_map": {},
"my_empty_vec": [],
"my_tuple": [
"💩",
42
] ]
}, }
"myInt": 123,
"myNullableEnum": null
} }
] ]
} }

View file

@ -3,12 +3,30 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"myInt": {
"type": "integer"
},
"myBool": { "myBool": {
"type": "boolean" "type": "boolean"
}, },
"myNullableEnum": {
"nullable": true
},
"myInnerStruct": { "myInnerStruct": {
"type": "object", "type": "object",
"properties": { "properties": {
"my_map": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"my_vec": {
"type": "array",
"items": {
"type": "string"
}
},
"my_empty_map": { "my_empty_map": {
"type": "object", "type": "object",
"additionalProperties": true "additionalProperties": true
@ -17,19 +35,13 @@
"type": "array", "type": "array",
"items": {} "items": {}
}, },
"my_map": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"my_tuple": { "my_tuple": {
"type": "array", "type": "array",
"items": [ "items": [
{ {
"type": "string", "type": "string",
"maxLength": 1, "minLength": 1,
"minLength": 1 "maxLength": 1
}, },
{ {
"type": "integer" "type": "integer"
@ -37,40 +49,28 @@
], ],
"maxItems": 2, "maxItems": 2,
"minItems": 2 "minItems": 2
},
"my_vec": {
"type": "array",
"items": {
"type": "string"
}
} }
} }
},
"myInt": {
"type": "integer"
},
"myNullableEnum": {
"nullable": true
} }
}, },
"example": { "example": {
"myInt": 123,
"myBool": true, "myBool": true,
"myNullableEnum": null,
"myInnerStruct": { "myInnerStruct": {
"my_empty_map": {},
"my_empty_vec": [],
"my_map": { "my_map": {
"": 0.0 "": 0.0
}, },
"my_tuple": [
"💩",
42
],
"my_vec": [ "my_vec": [
"hello", "hello",
"world" "world"
],
"my_empty_map": {},
"my_empty_vec": [],
"my_tuple": [
"💩",
42
] ]
}, }
"myInt": 123,
"myNullableEnum": null
} }
} }

View file

@ -11,11 +11,11 @@
}, },
"set": { "set": {
"type": "array", "type": "array",
"uniqueItems": true,
"items": { "items": {
"type": "integer", "type": "integer",
"format": "int" "format": "int"
}, }
"uniqueItems": true
} }
}, },
"required": [ "required": [

View file

@ -9,10 +9,10 @@
"$ref": "#/definitions/InnerStruct" "$ref": "#/definitions/InnerStruct"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"InnerStruct" "InnerStruct"
] ],
"additionalProperties": false
} }
], ],
"definitions": { "definitions": {

View file

@ -3,14 +3,14 @@
"title": "A", "title": "A",
"type": "object", "type": "object",
"properties": { "properties": {
"v": {
"type": "integer",
"format": "int32"
},
"x": { "x": {
"type": "integer", "type": "integer",
"format": "uint8", "format": "uint8",
"minimum": 0 "minimum": 0
},
"v": {
"type": "integer",
"format": "int32"
} }
}, },
"required": [ "required": [

View file

@ -3,12 +3,10 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"nonzero_signed": { "unsigned": {
"type": "integer", "type": "integer",
"format": "int32", "format": "uint32",
"not": { "minimum": 0
"const": 0
}
}, },
"nonzero_unsigned": { "nonzero_unsigned": {
"type": "integer", "type": "integer",
@ -19,10 +17,12 @@
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"unsigned": { "nonzero_signed": {
"type": "integer", "type": "integer",
"format": "uint32", "format": "int32",
"minimum": 0 "not": {
"const": 0
}
} }
}, },
"required": [ "required": [

View file

@ -3,10 +3,10 @@
"title": "OsStrings", "title": "OsStrings",
"type": "object", "type": "object",
"properties": { "properties": {
"borrowed": { "owned": {
"$ref": "#/definitions/OsString" "$ref": "#/definitions/OsString"
}, },
"owned": { "borrowed": {
"$ref": "#/definitions/OsString" "$ref": "#/definitions/OsString"
} }
}, },

View file

@ -3,14 +3,14 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"bound": { "range": {
"$ref": "#/definitions/Bound_of_string" "$ref": "#/definitions/Range_of_uint"
}, },
"inclusive": { "inclusive": {
"$ref": "#/definitions/Range_of_double" "$ref": "#/definitions/Range_of_double"
}, },
"range": { "bound": {
"$ref": "#/definitions/Range_of_uint" "$ref": "#/definitions/Bound_of_string"
} }
}, },
"required": [ "required": [
@ -19,6 +19,42 @@
"bound" "bound"
], ],
"definitions": { "definitions": {
"Range_of_uint": {
"type": "object",
"properties": {
"start": {
"type": "integer",
"format": "uint",
"minimum": 0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0
}
},
"required": [
"start",
"end"
]
},
"Range_of_double": {
"type": "object",
"properties": {
"start": {
"type": "number",
"format": "double"
},
"end": {
"type": "number",
"format": "double"
}
},
"required": [
"start",
"end"
]
},
"Bound_of_string": { "Bound_of_string": {
"oneOf": [ "oneOf": [
{ {
@ -48,42 +84,6 @@
"const": "Unbounded" "const": "Unbounded"
} }
] ]
},
"Range_of_double": {
"type": "object",
"properties": {
"end": {
"type": "number",
"format": "double"
},
"start": {
"type": "number",
"format": "double"
}
},
"required": [
"start",
"end"
]
},
"Range_of_uint": {
"type": "object",
"properties": {
"end": {
"type": "integer",
"format": "uint",
"minimum": 0
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0
}
},
"required": [
"start",
"end"
]
} }
} }
} }

View file

@ -6,27 +6,27 @@
"command_line": { "command_line": {
"type": "string" "type": "string"
}, },
"system_cpu_time": {
"allOf": [
{
"$ref": "#/definitions/Duration"
}
],
"default": "0.000000000s"
},
"user_cpu_time": {
"allOf": [
{
"$ref": "#/definitions/Duration"
}
],
"default": {
"nanos": 0,
"secs": 0
}
},
"wall_time": { "wall_time": {
"$ref": "#/definitions/Duration" "$ref": "#/definitions/Duration"
},
"user_cpu_time": {
"default": {
"secs": 0,
"nanos": 0
},
"allOf": [
{
"$ref": "#/definitions/Duration"
}
]
},
"system_cpu_time": {
"default": "0.000000000s",
"allOf": [
{
"$ref": "#/definitions/Duration"
}
]
} }
}, },
"required": [ "required": [
@ -37,13 +37,13 @@
"Duration": { "Duration": {
"type": "object", "type": "object",
"properties": { "properties": {
"nanos": {
"type": "integer",
"format": "int32"
},
"secs": { "secs": {
"type": "integer", "type": "integer",
"format": "int64" "format": "int64"
},
"nanos": {
"type": "integer",
"format": "int32"
} }
}, },
"required": [ "required": [

View file

@ -6,21 +6,21 @@
"byte_or_bool2": { "byte_or_bool2": {
"$ref": "#/definitions/Or_for_uint8_and_boolean" "$ref": "#/definitions/Or_for_uint8_and_boolean"
}, },
"fake_map": { "unit_or_t2": {
"type": "object", "$ref": "#/definitions/Or_for_null_and_int32"
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}, },
"s": { "s": {
"$ref": "#/definitions/Str" "$ref": "#/definitions/Str"
}, },
"unit_or_t2": { "fake_map": {
"$ref": "#/definitions/Or_for_null_and_int32" "type": "object",
"additionalProperties": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
}
} }
}, },
"required": [ "required": [
@ -30,17 +30,6 @@
"fake_map" "fake_map"
], ],
"definitions": { "definitions": {
"Or_for_null_and_int32": {
"anyOf": [
{
"type": "null"
},
{
"type": "integer",
"format": "int32"
}
]
},
"Or_for_uint8_and_boolean": { "Or_for_uint8_and_boolean": {
"anyOf": [ "anyOf": [
{ {
@ -53,6 +42,17 @@
} }
] ]
}, },
"Or_for_null_and_int32": {
"anyOf": [
{
"type": "null"
},
{
"type": "integer",
"format": "int32"
}
]
},
"Str": { "Str": {
"type": "string" "type": "string"
} }

View file

@ -15,18 +15,6 @@
"result2" "result2"
], ],
"definitions": { "definitions": {
"MyStruct": {
"type": "object",
"properties": {
"foo": {
"type": "integer",
"format": "int32"
}
},
"required": [
"foo"
]
},
"Result_of_MyStruct_or_Array_of_string": { "Result_of_MyStruct_or_Array_of_string": {
"oneOf": [ "oneOf": [
{ {
@ -56,6 +44,18 @@
} }
] ]
}, },
"MyStruct": {
"type": "object",
"properties": {
"foo": {
"type": "integer",
"format": "int32"
}
},
"required": [
"foo"
]
},
"Result_of_boolean_or_null": { "Result_of_boolean_or_null": {
"oneOf": [ "oneOf": [
{ {

View file

@ -3,9 +3,6 @@
"title": "a-new-name-Array_of_string-int32-int32", "title": "a-new-name-Array_of_string-int32-int32",
"type": "object", "type": "object",
"properties": { "properties": {
"inner": {
"$ref": "#/definitions/another-new-name"
},
"t": { "t": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
@ -21,6 +18,9 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"inner": {
"$ref": "#/definitions/another-new-name"
} }
}, },
"required": [ "required": [

View file

@ -3,9 +3,6 @@
"title": "MyStruct_for_int32_and_null_and_boolean_and_Array_of_string", "title": "MyStruct_for_int32_and_null_and_boolean_and_Array_of_string",
"type": "object", "type": "object",
"properties": { "properties": {
"inner": {
"$ref": "#/definitions/MySimpleStruct"
},
"t": { "t": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
@ -21,6 +18,9 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"inner": {
"$ref": "#/definitions/MySimpleStruct"
} }
}, },
"required": [ "required": [

View file

@ -3,12 +3,12 @@
"title": "MixedGenericStruct_for_MyStruct_for_int32_and_null_and_boolean_and_Array_of_string_and_42_and_z", "title": "MixedGenericStruct_for_MyStruct_for_int32_and_null_and_boolean_and_Array_of_string_and_42_and_z",
"type": "object", "type": "object",
"properties": { "properties": {
"generic": {
"$ref": "#/definitions/MyStruct_for_int32_and_null_and_boolean_and_Array_of_string"
},
"foo": { "foo": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
},
"generic": {
"$ref": "#/definitions/MyStruct_for_int32_and_null_and_boolean_and_Array_of_string"
} }
}, },
"required": [ "required": [
@ -16,24 +16,9 @@
"foo" "foo"
], ],
"definitions": { "definitions": {
"MySimpleStruct": {
"type": "object",
"properties": {
"foo": {
"type": "integer",
"format": "int32"
}
},
"required": [
"foo"
]
},
"MyStruct_for_int32_and_null_and_boolean_and_Array_of_string": { "MyStruct_for_int32_and_null_and_boolean_and_Array_of_string": {
"type": "object", "type": "object",
"properties": { "properties": {
"inner": {
"$ref": "#/definitions/MySimpleStruct"
},
"t": { "t": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
@ -49,6 +34,9 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"inner": {
"$ref": "#/definitions/MySimpleStruct"
} }
}, },
"required": [ "required": [
@ -58,6 +46,18 @@
"w", "w",
"inner" "inner"
] ]
},
"MySimpleStruct": {
"type": "object",
"properties": {
"foo": {
"type": "integer",
"format": "int32"
}
},
"required": [
"foo"
]
} }
} }
} }

View file

@ -3,6 +3,19 @@
"title": "Outer", "title": "Outer",
"type": "object", "type": "object",
"properties": { "properties": {
"int": {
"type": "integer",
"format": "int32",
"examples": [
8,
null
]
},
"values": {
"type": "object",
"additionalProperties": true
},
"value": true,
"inner": { "inner": {
"anyOf": [ "anyOf": [
{ {
@ -12,19 +25,6 @@
"type": "null" "type": "null"
} }
] ]
},
"int": {
"type": "integer",
"format": "int32",
"examples": [
8,
null
]
},
"value": true,
"values": {
"type": "object",
"additionalProperties": true
} }
}, },
"required": [ "required": [
@ -52,10 +52,10 @@
"properties": { "properties": {
"ValueNewType": true "ValueNewType": true
}, },
"additionalProperties": false,
"required": [ "required": [
"ValueNewType" "ValueNewType"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -3,23 +3,23 @@
"title": "Outer", "title": "Outer",
"type": "object", "type": "object",
"properties": { "properties": {
"inner": {
"allOf": [
{
"$ref": "#/components/schemas/Inner"
}
],
"nullable": true
},
"int": { "int": {
"type": "integer", "type": "integer",
"format": "int32", "format": "int32",
"example": 8 "example": 8
}, },
"value": {},
"values": { "values": {
"type": "object", "type": "object",
"additionalProperties": true "additionalProperties": true
},
"value": {},
"inner": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Inner"
}
]
} }
}, },
"required": [ "required": [
@ -49,10 +49,10 @@
"properties": { "properties": {
"ValueNewType": {} "ValueNewType": {}
}, },
"additionalProperties": false,
"required": [ "required": [
"ValueNewType" "ValueNewType"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -3,6 +3,19 @@
"title": "Outer", "title": "Outer",
"type": "object", "type": "object",
"properties": { "properties": {
"int": {
"type": "integer",
"format": "int32",
"examples": [
8,
null
]
},
"values": {
"type": "object",
"additionalProperties": true
},
"value": true,
"inner": { "inner": {
"anyOf": [ "anyOf": [
{ {
@ -12,19 +25,6 @@
"type": "null" "type": "null"
} }
] ]
},
"int": {
"type": "integer",
"format": "int32",
"examples": [
8,
null
]
},
"value": true,
"values": {
"type": "object",
"additionalProperties": true
} }
}, },
"required": [ "required": [
@ -52,10 +52,10 @@
"properties": { "properties": {
"ValueNewType": true "ValueNewType": true
}, },
"additionalProperties": false,
"required": [ "required": [
"ValueNewType" "ValueNewType"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -5,6 +5,12 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"t": {
"type": "string",
"enum": [
"Struct"
]
},
"c": { "c": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -15,12 +21,6 @@
"required": [ "required": [
"foo" "foo"
] ]
},
"t": {
"type": "string",
"enum": [
"Struct"
]
} }
}, },
"required": [ "required": [
@ -31,14 +31,14 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"type": "boolean"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"NewType" "NewType"
] ]
},
"c": {
"type": "boolean"
} }
}, },
"required": [ "required": [
@ -49,6 +49,12 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"t": {
"type": "string",
"enum": [
"Tuple"
]
},
"c": { "c": {
"type": "array", "type": "array",
"items": [ "items": [
@ -60,14 +66,8 @@
"format": "int32" "format": "int32"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
},
"t": {
"type": "string",
"enum": [
"Tuple"
]
} }
}, },
"required": [ "required": [
@ -78,14 +78,14 @@
{ {
"type": "object", "type": "object",
"properties": { "properties": {
"c": {
"type": "boolean"
},
"t": { "t": {
"type": "string", "type": "string",
"enum": [ "enum": [
"Unit" "Unit"
] ]
},
"c": {
"type": "boolean"
} }
}, },
"required": [ "required": [

View file

@ -17,10 +17,10 @@
] ]
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"struct" "struct"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -29,10 +29,10 @@
"type": "boolean" "type": "boolean"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"newType" "newType"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -48,14 +48,14 @@
"format": "int32" "format": "int32"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"tuple" "tuple"
] ],
"additionalProperties": false
}, },
{ {
"type": "object", "type": "object",
@ -64,10 +64,10 @@
"type": "boolean" "type": "boolean"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"unit" "unit"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -27,8 +27,8 @@
"format": "int32" "format": "int32"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
}, },
{ {
"type": "boolean" "type": "boolean"

View file

@ -3,15 +3,15 @@
"title": "Struct", "title": "Struct",
"type": "object", "type": "object",
"properties": { "properties": {
"foo": {
"type": "boolean"
},
"bar": { "bar": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"baz": { "baz": {
"type": "boolean" "type": "boolean"
},
"foo": {
"type": "boolean"
} }
}, },
"required": [ "required": [

View file

@ -14,6 +14,6 @@
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 3, "minItems": 3,
"minItems": 3 "maxItems": 3
} }

View file

@ -16,10 +16,10 @@
"format": "float" "format": "float"
} }
}, },
"additionalProperties": false,
"required": [ "required": [
"Included1" "Included1"
] ],
"additionalProperties": false
} }
] ]
} }

View file

@ -3,18 +3,18 @@
"title": "MyStruct", "title": "MyStruct",
"type": "object", "type": "object",
"properties": { "properties": {
"included": {
"type": "null"
},
"readable": { "readable": {
"type": "string", "type": "string",
"default": "", "readOnly": true,
"readOnly": true "default": ""
}, },
"writable": { "writable": {
"type": "number", "type": "number",
"format": "float", "format": "float",
"writeOnly": true "writeOnly": true
},
"included": {
"type": "null"
} }
}, },
"required": [ "required": [

View file

@ -11,6 +11,6 @@
"type": "null" "type": "null"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }

View file

@ -3,6 +3,10 @@
"title": "Struct", "title": "Struct",
"type": "object", "type": "object",
"properties": { "properties": {
"foo": {
"type": "integer",
"format": "int32"
},
"bar": { "bar": {
"type": "boolean" "type": "boolean"
}, },
@ -11,10 +15,6 @@
"string", "string",
"null" "null"
] ]
},
"foo": {
"type": "integer",
"format": "int32"
} }
}, },
"additionalProperties": false, "additionalProperties": false,

View file

@ -3,6 +3,10 @@
"title": "Struct", "title": "Struct",
"type": "object", "type": "object",
"properties": { "properties": {
"foo": {
"type": "integer",
"format": "int32"
},
"bar": { "bar": {
"type": "boolean" "type": "boolean"
}, },
@ -11,10 +15,6 @@
"string", "string",
"null" "null"
] ]
},
"foo": {
"type": "integer",
"format": "int32"
} }
}, },
"required": [ "required": [

View file

@ -17,6 +17,6 @@
] ]
} }
], ],
"maxItems": 3, "minItems": 3,
"minItems": 3 "maxItems": 3
} }

View file

@ -26,8 +26,8 @@
"format": "int32" "format": "int32"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }
} }
} }

View file

@ -3,61 +3,17 @@
"title": "Struct", "title": "Struct",
"type": "object", "type": "object",
"properties": { "properties": {
"contains_str1": {
"type": "string",
"pattern": "substring\\.\\.\\."
},
"contains_str2": {
"type": "string",
"pattern": "substring\\.\\.\\."
},
"email_address": {
"type": "string",
"format": "email"
},
"homepage": {
"type": "string",
"format": "uri"
},
"map_contains": {
"type": "object",
"additionalProperties": {
"type": "null"
},
"required": [
"map_key"
]
},
"min_max": { "min_max": {
"type": "number", "type": "number",
"format": "float", "format": "float",
"maximum": 100, "minimum": 0.01,
"minimum": 0.01 "maximum": 100
}, },
"min_max2": { "min_max2": {
"type": "number", "type": "number",
"format": "float", "format": "float",
"maximum": 1000, "minimum": 1,
"minimum": 1 "maximum": 1000
},
"non_empty_str": {
"type": "string",
"maxLength": 100,
"minLength": 1
},
"non_empty_str2": {
"type": "string",
"maxLength": 1000,
"minLength": 1
},
"pair": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"maxItems": 2,
"minItems": 2
}, },
"regex_str1": { "regex_str1": {
"type": "string", "type": "string",
@ -71,13 +27,57 @@
"type": "string", "type": "string",
"pattern": "^\\d+$" "pattern": "^\\d+$"
}, },
"required_option": { "contains_str1": {
"type": "boolean" "type": "string",
"pattern": "substring\\.\\.\\."
},
"contains_str2": {
"type": "string",
"pattern": "substring\\.\\.\\."
},
"email_address": {
"type": "string",
"format": "email"
}, },
"tel": { "tel": {
"type": "string", "type": "string",
"format": "phone" "format": "phone"
}, },
"homepage": {
"type": "string",
"format": "uri"
},
"non_empty_str": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"non_empty_str2": {
"type": "string",
"minLength": 1,
"maxLength": 1000
},
"pair": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"minItems": 2,
"maxItems": 2
},
"map_contains": {
"type": "object",
"additionalProperties": {
"type": "null"
},
"required": [
"map_key"
]
},
"required_option": {
"type": "boolean"
},
"x": { "x": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"

View file

@ -7,11 +7,11 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"maxLength": 100, "minLength": 5,
"minLength": 5 "maxLength": 100
}, },
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
}, },
"slice_str_contains": { "slice_str_contains": {
"type": "array", "type": "array",
@ -20,33 +20,6 @@
"pattern": "substring\\.\\.\\." "pattern": "substring\\.\\.\\."
} }
}, },
"vec_i32_range": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"maximum": 10,
"minimum": -10
}
},
"vec_str_length": {
"type": "array",
"items": {
"type": "string",
"maxLength": 100,
"minLength": 1
}
},
"vec_str_length2": {
"type": "array",
"items": {
"type": "string",
"maxLength": 100,
"minLength": 1
},
"maxItems": 3,
"minItems": 1
},
"vec_str_regex": { "vec_str_regex": {
"type": "array", "type": "array",
"items": { "items": {
@ -54,12 +27,39 @@
"pattern": "^[Hh]ello\\b" "pattern": "^[Hh]ello\\b"
} }
}, },
"vec_str_length": {
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 100
}
},
"vec_str_length2": {
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"minItems": 1,
"maxItems": 3
},
"vec_str_url": { "vec_str_url": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"format": "uri" "format": "uri"
} }
},
"vec_i32_range": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"minimum": -10,
"maximum": 10
}
} }
}, },
"required": [ "required": [

View file

@ -3,6 +3,6 @@
"title": "NewType", "title": "NewType",
"type": "integer", "type": "integer",
"format": "uint8", "format": "uint8",
"maximum": 10, "minimum": 0,
"minimum": 0 "maximum": 10
} }

View file

@ -3,61 +3,17 @@
"title": "Struct2", "title": "Struct2",
"type": "object", "type": "object",
"properties": { "properties": {
"contains_str1": {
"type": "string",
"pattern": "substring\\.\\.\\."
},
"contains_str2": {
"type": "string",
"pattern": "substring\\.\\.\\."
},
"email_address": {
"type": "string",
"format": "email"
},
"homepage": {
"type": "string",
"format": "uri"
},
"map_contains": {
"type": "object",
"additionalProperties": {
"type": "null"
},
"required": [
"map_key"
]
},
"min_max": { "min_max": {
"type": "number", "type": "number",
"format": "float", "format": "float",
"maximum": 100, "minimum": 0.01,
"minimum": 0.01 "maximum": 100
}, },
"min_max2": { "min_max2": {
"type": "number", "type": "number",
"format": "float", "format": "float",
"maximum": 1000, "minimum": 1,
"minimum": 1 "maximum": 1000
},
"non_empty_str": {
"type": "string",
"maxLength": 100,
"minLength": 1
},
"non_empty_str2": {
"type": "string",
"maxLength": 1000,
"minLength": 1
},
"pair": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"maxItems": 2,
"minItems": 2
}, },
"regex_str1": { "regex_str1": {
"type": "string", "type": "string",
@ -71,13 +27,57 @@
"type": "string", "type": "string",
"pattern": "^\\d+$" "pattern": "^\\d+$"
}, },
"required_option": { "contains_str1": {
"type": "boolean" "type": "string",
"pattern": "substring\\.\\.\\."
},
"contains_str2": {
"type": "string",
"pattern": "substring\\.\\.\\."
},
"email_address": {
"type": "string",
"format": "email"
}, },
"tel": { "tel": {
"type": "string", "type": "string",
"format": "phone" "format": "phone"
}, },
"homepage": {
"type": "string",
"format": "uri"
},
"non_empty_str": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"non_empty_str2": {
"type": "string",
"minLength": 1,
"maxLength": 1000
},
"pair": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"minItems": 2,
"maxItems": 2
},
"map_contains": {
"type": "object",
"additionalProperties": {
"type": "null"
},
"required": [
"map_key"
]
},
"required_option": {
"type": "boolean"
},
"x": { "x": {
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"

View file

@ -6,13 +6,13 @@
{ {
"type": "integer", "type": "integer",
"format": "uint8", "format": "uint8",
"maximum": 10, "minimum": 0,
"minimum": 0 "maximum": 10
}, },
{ {
"type": "boolean" "type": "boolean"
} }
], ],
"maxItems": 2, "minItems": 2,
"minItems": 2 "maxItems": 2
} }