Use $defs instead of definitions in draft 2019-09

This also changes the strategy for running visitors on subschemas - it is now done eagerly, as soon as they're added to the definitions map.
This commit is contained in:
Graham Esau 2024-05-19 18:07:51 +01:00
parent 22e89a5dd6
commit 95475ad1b4
5 changed files with 98 additions and 74 deletions

View file

@ -14,7 +14,7 @@
},
"my_unit": {
"description": "A unit struct instance",
"$ref": "#/definitions/MyUnitStruct"
"$ref": "#/$defs/MyUnitStruct"
}
},
"required": [
@ -22,7 +22,7 @@
"my_undocumented_bool",
"my_unit"
],
"definitions": {
"$defs": {
"MyUnitStruct": {
"title": "A Unit",
"type": "null"

View file

@ -19,7 +19,7 @@
"inner": {
"anyOf": [
{
"$ref": "#/definitions/Inner"
"$ref": "#/$defs/Inner"
},
{
"type": "null"
@ -32,7 +32,7 @@
"values",
"value"
],
"definitions": {
"$defs": {
"Inner": {
"oneOf": [
{

View file

@ -27,34 +27,36 @@
"values",
"value"
],
"definitions": {
"Inner": {
"oneOf": [
{
"type": "string",
"enum": [
"UndocumentedUnit1",
"UndocumentedUnit2"
]
},
{
"description": "This is a documented unit variant",
"type": "string",
"enum": [
"DocumentedUnit"
]
},
{
"type": "object",
"properties": {
"ValueNewType": {}
"components": {
"schemas": {
"Inner": {
"oneOf": [
{
"type": "string",
"enum": [
"UndocumentedUnit1",
"UndocumentedUnit2"
]
},
"required": [
"ValueNewType"
],
"additionalProperties": false
}
]
{
"description": "This is a documented unit variant",
"type": "string",
"enum": [
"DocumentedUnit"
]
},
{
"type": "object",
"properties": {
"ValueNewType": {}
},
"required": [
"ValueNewType"
],
"additionalProperties": false
}
]
}
}
}
}