Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/quicktype-core/src/input/JSONSchemaInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,11 @@ async function addTypesInSchema(
) {
additionalProperties = schema.patternProperties[".*"];
}

// Handle unevaluatedProperties if additionalProperties is not defined
if (additionalProperties === undefined && schema.unevaluatedProperties !== undefined) {
additionalProperties = schema.unevaluatedProperties;
}

const objectAttributes = combineTypeAttributes(
"union",
Expand Down
14 changes: 14 additions & 0 deletions test/inputs/schema/unevaluated-properties.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"config": {
"name": "test-config",
"settings": {
"option1": [
{"key": "foo", "value": "bar"},
{"key": "baz", "value": "qux"}
],
"option2": [
{"key": "hello", "value": "world"}
]
}
}
}
19 changes: 19 additions & 0 deletions test/inputs/schema/unevaluated-properties.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"config": {
"name": "multiple-versions",
"settings": {
"v1.0.0": [
{"key": "checksum1", "value": "abc123"},
{"key": "checksum2", "value": "def456"}
],
"v1.1.0": [
{"key": "checksum1", "value": "ghi789"}
],
"latest": [
{"key": "checksum1", "value": "jkl012"},
{"key": "checksum2", "value": "mno345"},
{"key": "checksum3", "value": "pqr678"}
]
}
}
}
46 changes: 46 additions & 0 deletions test/inputs/schema/unevaluated-properties.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "unevaluated-properties.schema",
"title": "Test unevaluatedProperties support",
"type": "object",
"properties": {
"config": {
"$ref": "#/$defs/Config"
}
},
"$defs": {
"Config": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"settings": {
"$ref": "#/$defs/Settings"
}
}
},
"Settings": {
"type": "object",
"properties": {},
"unevaluatedProperties": {
"type": "array",
"items": {
"$ref": "#/$defs/Item"
}
}
},
"Item": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": ["key", "value"]
}
}
}
Loading