parent
01632b37fc
commit
a555d7739a
6 changed files with 199 additions and 54 deletions
|
@ -2,11 +2,22 @@ mod util;
|
|||
use schemars::{JsonSchema, Map};
|
||||
use util::*;
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
pub struct UnitStruct;
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
pub struct Struct {
|
||||
foo: i32,
|
||||
bar: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
#[schemars(rename_all = "camelCase")]
|
||||
pub enum External {
|
||||
UnitOne,
|
||||
StringMap(Map<String, String>),
|
||||
UnitStructNewType(UnitStruct),
|
||||
StructNewType(Struct),
|
||||
Struct { foo: i32, bar: bool },
|
||||
UnitTwo,
|
||||
Tuple(i32, bool),
|
||||
|
@ -22,6 +33,8 @@ fn enum_external_tag() -> TestResult {
|
|||
pub enum Internal {
|
||||
UnitOne,
|
||||
StringMap(Map<String, String>),
|
||||
UnitStructNewType(UnitStruct),
|
||||
StructNewType(Struct),
|
||||
Struct { foo: i32, bar: bool },
|
||||
UnitTwo,
|
||||
}
|
||||
|
@ -36,6 +49,8 @@ fn enum_internal_tag() -> TestResult {
|
|||
pub enum Untagged {
|
||||
UnitOne,
|
||||
StringMap(Map<String, String>),
|
||||
UnitStructNewType(UnitStruct),
|
||||
StructNewType(Struct),
|
||||
Struct { foo: i32, bar: bool },
|
||||
Tuple(i32, bool),
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"stringMap"
|
||||
],
|
||||
"properties": {
|
||||
"stringMap": {
|
||||
"type": "object",
|
||||
|
@ -17,16 +20,42 @@
|
|||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"stringMap"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"unitStructNewType"
|
||||
],
|
||||
"properties": {
|
||||
"unitStructNewType": {
|
||||
"$ref": "#/definitions/UnitStruct"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"structNewType"
|
||||
],
|
||||
"properties": {
|
||||
"structNewType": {
|
||||
"$ref": "#/definitions/Struct"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"struct"
|
||||
],
|
||||
"properties": {
|
||||
"struct": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
|
@ -35,19 +64,15 @@
|
|||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"struct"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"tuple"
|
||||
],
|
||||
"properties": {
|
||||
"tuple": {
|
||||
"type": "array",
|
||||
|
@ -63,10 +88,28 @@
|
|||
"maxItems": 2,
|
||||
"minItems": 2
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tuple"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"definitions": {
|
||||
"Struct": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UnitStruct": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,9 @@
|
|||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"typeProperty"
|
||||
],
|
||||
"properties": {
|
||||
"typeProperty": {
|
||||
"type": "string",
|
||||
|
@ -11,13 +14,13 @@
|
|||
"UnitOne"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"typeProperty"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"typeProperty"
|
||||
],
|
||||
"properties": {
|
||||
"typeProperty": {
|
||||
"type": "string",
|
||||
|
@ -26,15 +29,54 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"typeProperty"
|
||||
],
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"typeProperty"
|
||||
],
|
||||
"properties": {
|
||||
"typeProperty": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UnitStructNewType"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"bar",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"typeProperty": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"StructNewType"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"bar",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
|
@ -49,15 +91,13 @@
|
|||
"Struct"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"typeProperty"
|
||||
],
|
||||
"properties": {
|
||||
"typeProperty": {
|
||||
"type": "string",
|
||||
|
@ -65,10 +105,7 @@
|
|||
"UnitTwo"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"typeProperty"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -11,8 +11,18 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/UnitStruct"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Struct"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
|
@ -21,11 +31,7 @@
|
|||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
|
@ -41,5 +47,26 @@
|
|||
"maxItems": 2,
|
||||
"minItems": 2
|
||||
}
|
||||
]
|
||||
],
|
||||
"definitions": {
|
||||
"Struct": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UnitStruct": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue