From 506e3eaeeca4f8ef32b6ff48de9823350dc722fe Mon Sep 17 00:00:00 2001 From: Loic Date: Thu, 9 Mar 2023 10:22:58 +0100 Subject: [PATCH 1/2] [doc] add a json schema for constraints --- .../resources/constraint.schema.json | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 documentation/configuration/resources/constraint.schema.json diff --git a/documentation/configuration/resources/constraint.schema.json b/documentation/configuration/resources/constraint.schema.json new file mode 100644 index 0000000..8ab72e3 --- /dev/null +++ b/documentation/configuration/resources/constraint.schema.json @@ -0,0 +1,189 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema#", + "title": "Generated schema for Root", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "defaultPreferredCostRatio": { + "type": "number" + }, + "defaultAvoidCostRatio": { + "type": "number" + }, + "values": { + "type": "array", + "items": { + "anyOf" : [ + {"type": "object", + "properties": { + "keyType": { + "type": "string", + "enum": ["name-osrm"] + }, + "key": { + "type": "string" + }, + "availableConstraintType": { + "type": "array", + "items": { + "type": "string" + } + }, + "availableValues": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string" + }, + "field": { + "type": "string" + } + }, + "required": [ + "value", + "field" + ] + } + } + }, + "required": [ + "keyType", + "key", + "availableConstraintType", + "availableValues" + ] + }, + {"type": "object", + "properties": { + "keyType": { + "type": "string", + "enum": ["name-pgr"] + }, + "key": { + "type": "string" + }, + "availableConstraintType": { + "type": "array", + "items": { + "type": "string" + } + }, + "availableValues": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string" + }, + "field": { + "type": "string" + }, + "condition": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "type", + "value" + ] + } + }, + "required": [ + "value", + "field", + "condition" + ] + } + } + }, + "required": [ + "keyType", + "key", + "availableConstraintType", + "availableValues" + ]}, + {"type": "object", + "properties": { + "keyType": { + "type": "string", + "enum": ["numerical-pgr"] + }, + "key": { + "type": "string" + }, + "availableConstraintType": { + "type": "array", + "items": { + "type": "string" + } + }, + "field": { + "type": "string" + } + }, + "required": [ + "keyType", + "key", + "availableConstraintType", + "field" + ]}, + {"type": "object", + "properties": { + "keyType": { + "type": "string", + "enum": ["name-valhalla"] + }, + "key": { + "type": "string" + }, + "availableConstraintType": { + "type": "array", + "items": { + "type": "string" + } + }, + "availableValues": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string" + }, + "field": { + "type": "string" + } + }, + "required": [ + "value", + "field" + ] + } + } + }, + "required": [ + "keyType", + "key", + "availableConstraintType", + "availableValues" + ]} + ] + }, + "required": [ + "id", + "values" + ] +} +} +} \ No newline at end of file From 0a340cd6b90bbb39558b884b3e55c9908a1998ee Mon Sep 17 00:00:00 2001 From: lgrd Date: Thu, 9 Mar 2023 14:48:08 +0100 Subject: [PATCH 2/2] [fix] add a little enum --- documentation/configuration/resources/constraint.schema.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/documentation/configuration/resources/constraint.schema.json b/documentation/configuration/resources/constraint.schema.json index 8ab72e3..72d80bd 100644 --- a/documentation/configuration/resources/constraint.schema.json +++ b/documentation/configuration/resources/constraint.schema.json @@ -4,7 +4,8 @@ "type": "object", "properties": { "id": { - "type": "string" + "type": "string", + "enum": ["constraints"] }, "defaultPreferredCostRatio": { "type": "number" @@ -186,4 +187,4 @@ ] } } -} \ No newline at end of file +}