bringing back type constants for validation via new overrides vocabulary
This commit is contained in:
@ -465,7 +465,7 @@ pub fn property_merging_schemas() -> JsonB {
|
||||
"properties": {
|
||||
"id": { "type": "string" },
|
||||
"name": { "type": "string" },
|
||||
"type": { "type": "string" }
|
||||
"type": { "type": "string", "const": "entity" }
|
||||
},
|
||||
"required": ["id"]
|
||||
}]
|
||||
@ -476,6 +476,7 @@ pub fn property_merging_schemas() -> JsonB {
|
||||
"$id": "user",
|
||||
"$ref": "entity",
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "user", "override": true },
|
||||
"password": { "type": "string", "minLength": 8 }
|
||||
},
|
||||
"required": ["password"]
|
||||
@ -487,6 +488,7 @@ pub fn property_merging_schemas() -> JsonB {
|
||||
"$id": "person",
|
||||
"$ref": "user",
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "person", "override": true },
|
||||
"first_name": { "type": "string", "minLength": 1 },
|
||||
"last_name": { "type": "string", "minLength": 1 }
|
||||
},
|
||||
@ -852,7 +854,10 @@ pub fn type_matching_schemas() -> JsonB {
|
||||
"schemas": [{
|
||||
"$id": "entity",
|
||||
"type": "object",
|
||||
"properties": { "type": { "type": "string" }, "name": { "type": "string" } },
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "entity" },
|
||||
"name": { "type": "string" }
|
||||
},
|
||||
"required": ["type", "name"]
|
||||
}]
|
||||
},
|
||||
@ -861,7 +866,10 @@ pub fn type_matching_schemas() -> JsonB {
|
||||
"schemas": [{
|
||||
"$id": "job",
|
||||
"$ref": "entity",
|
||||
"properties": { "job_id": { "type": "string" } },
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "job", "override": true },
|
||||
"job_id": { "type": "string" }
|
||||
},
|
||||
"required": ["job_id"]
|
||||
}]
|
||||
},
|
||||
@ -871,7 +879,10 @@ pub fn type_matching_schemas() -> JsonB {
|
||||
{
|
||||
"$id": "super_job",
|
||||
"$ref": "job",
|
||||
"properties": { "manager_id": { "type": "string" } },
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "super_job", "override": true },
|
||||
"manager_id": { "type": "string" }
|
||||
},
|
||||
"required": ["manager_id"]
|
||||
},
|
||||
{
|
||||
@ -912,47 +923,59 @@ pub fn type_matching_schemas() -> JsonB {
|
||||
pub fn union_schemas() -> JsonB {
|
||||
let enums = json!([]);
|
||||
let types = json!([
|
||||
{
|
||||
"name": "union_base",
|
||||
"schemas": [{
|
||||
"$id": "union_base",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "union_base" },
|
||||
"id": { "type": "string" }
|
||||
},
|
||||
"required": ["type", "id"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "union_a",
|
||||
"schemas": [{
|
||||
"$id": "union_a",
|
||||
"type": "object",
|
||||
"$ref": "union_base",
|
||||
"properties": {
|
||||
"type": { "const": "union_a" },
|
||||
"type": { "type": "string", "const": "union_a", "override": true },
|
||||
"prop_a": { "type": "string" }
|
||||
},
|
||||
"required": ["type", "prop_a"]
|
||||
"required": ["prop_a"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "union_b",
|
||||
"schemas": [{
|
||||
"$id": "union_b",
|
||||
"type": "object",
|
||||
"$ref": "union_base",
|
||||
"properties": {
|
||||
"type": { "const": "union_b" },
|
||||
"type": { "type": "string", "const": "union_b", "override": true },
|
||||
"prop_b": { "type": "number" }
|
||||
},
|
||||
"required": ["type", "prop_b"]
|
||||
"required": ["prop_b"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "union_c",
|
||||
"schemas": [{
|
||||
"$id": "union_c",
|
||||
"type": "object",
|
||||
"$ref": "union_base",
|
||||
"properties": {
|
||||
"type": { "const": "union_c" },
|
||||
"type": { "type": "string", "const": "union_c", "override": true },
|
||||
"prop_c": { "type": "boolean" }
|
||||
},
|
||||
"required": ["type", "prop_c"]
|
||||
"required": ["prop_c"]
|
||||
}]
|
||||
}
|
||||
]);
|
||||
|
||||
let puncs = json!([{
|
||||
"name": "union_test",
|
||||
"public": false,
|
||||
"public": true,
|
||||
"schemas": [{
|
||||
"$id": "union_test.request",
|
||||
"type": "object",
|
||||
@ -975,23 +998,47 @@ pub fn union_schemas() -> JsonB {
|
||||
pub fn nullable_union_schemas() -> JsonB {
|
||||
let enums = json!([]);
|
||||
let types = json!([
|
||||
{
|
||||
"name": "thing_base",
|
||||
"schemas": [{
|
||||
"$id": "thing_base",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "thing_base" },
|
||||
"id": { "type": "string" }
|
||||
},
|
||||
"required": ["type", "id"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "thing_a",
|
||||
"schemas": [{
|
||||
"$id": "thing_a",
|
||||
"type": "object",
|
||||
"$ref": "thing_base",
|
||||
"properties": {
|
||||
"type": { "const": "thing_a" },
|
||||
"type": { "type": "string", "const": "thing_a", "override": true },
|
||||
"prop_a": { "type": "string" }
|
||||
},
|
||||
"required": ["type", "prop_a"]
|
||||
"required": ["prop_a"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "thing_b",
|
||||
"schemas": [{
|
||||
"$id": "thing_b",
|
||||
"$ref": "thing_base",
|
||||
"properties": {
|
||||
"type": { "type": "string", "const": "thing_b", "override": true },
|
||||
"prop_b": { "type": "string" }
|
||||
},
|
||||
"required": ["prop_b"]
|
||||
}]
|
||||
}
|
||||
]);
|
||||
|
||||
let puncs = json!([{
|
||||
"name": "nullable_union_test",
|
||||
"public": false,
|
||||
"public": true,
|
||||
"schemas": [{
|
||||
"$id": "nullable_union_test.request",
|
||||
"type": "object",
|
||||
@ -999,6 +1046,7 @@ pub fn nullable_union_schemas() -> JsonB {
|
||||
"nullable_prop": {
|
||||
"oneOf": [
|
||||
{ "$ref": "thing_a" },
|
||||
{ "$ref": "thing_b" },
|
||||
{ "type": "null" }
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user