From c79d909b4658376593a7495cc8414bd499baeff1 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Sat, 19 Dec 2020 09:21:50 +0100 Subject: [PATCH 1/6] Updates city_schema.json --- schema/city_schema.json | 193 ++++++++++++++++++++++++++-------------- 1 file changed, 127 insertions(+), 66 deletions(-) diff --git a/schema/city_schema.json b/schema/city_schema.json index 6513da2..a346dd6 100644 --- a/schema/city_schema.json +++ b/schema/city_schema.json @@ -1,67 +1,128 @@ { - "$schema":"http://jkliemann.de/parkendd/media/city_schema.json", - "title":"ParkenDD JSON API", - "description":"JSON required by ParkenDD app to show parking lots", - "type":"array", - "items":{ - "type":"object", - "properties":{ - "name":{ - "description":"Name of parking lot category", - "type":"string" - }, - "lots":{ - "description":"Parking lots in this category", - "type":"array", - "items":{ - "type":"object", - "properties":{ - "name":{ - "description":"Name of parking lot", - "type":"string" - }, - "count":{ - "description":"Count of available parking lots", - "type":"integer" - }, - "free":{ - "description":"Count of free parking lots", - "type":"integer" - }, - "state":{ - "description":"State of the parking lot", - "type":"string", - "enum":["nodata","closed","many","few","full"] - }, - "lat":{ - "description":"latitude of the parking lot", - "type":"string" - }, - "lon":{ - "description":"longitude of the parking lot", - "type":"string" - }, - "forecast":{ - "description":"shows if forecast is available for this spot", - "type":"boolean" - }, - "url":{ - "description":"A URL of a web resource where more information can be viewed", - "type":"string" - }, - "opening_hours":{ - "description":"Opening hours of this lot in OpenStreetMap format (https://wiki.openstreetmap.org/wiki/Key:opening_hours)", - "type":"string" - }, - "fee_hours":{ - "description":"Hours during which usage of this lot incurrs fees in OpenStreetMap format (https://wiki.openstreetmap.org/wiki/Key:opening_hours). It is implied that outside those hours usage is free.", - "type":"string" - } - }, - "required":["name", "count", "state", "forecast"] - } - } - }, - "required":["name", "lots"] - } -} + "$schema": "http://jkliemann.de/parkendd/media/city_schema.json", + "title": "ParkenDD JSON API", + "description": "JSON required by ParkenDD app to show parking lots", + "type": "object", + "properties": { + "last_downloaded": { + "type": "string", + "format": "date-time" + }, + "last_updated": { + "type": "string", + "format": "date-time" + }, + "lots": { + "type": "array", + "items": { + "type": "object", + "properties": { + "address": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "coords": { + "oneOf": [ + { + "type": "object", + "properties": { + "lat": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "lng": { + "type": "number", + "minimum": -180, + "maximum": 180 + } + } + }, + { + "type": "null" + } + ] + }, + "forecast": { + "type": "boolean" + }, + "free": { + "type": "integer", + "minimum": 0 + }, + "id": { + "type": "string" + }, + "lot_type": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "name": { + "type": "string" + }, + "region": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "state": { + "enum": [ + "open", + "nodata", + "closed", + "many", + "few", + "full" + ] + }, + "total": { + "type": "integer", + "minimum": 0 + }, + "opening_hours": { + "type": "string" + }, + "fee_hours": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri" + } + }, + "required": [ + "forecast", + "free", + "id", + "name", + "state", + "total" + ], + "additionalProperties": false + } + } + }, + "required": [ + "last_downloaded", + "last_updated", + "lots" + ], + "additionalProperties": false +} \ No newline at end of file From dab742beb6527b3f0de622e6c290682f2c6d9d05 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Mon, 21 Dec 2020 23:36:01 +0100 Subject: [PATCH 2/6] Freeze feedparser to pre Python 3.6 version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 97e7b90..7430884 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ beautifulsoup4 Flask requests -feedparser +feedparser==5.2.1 pytz psycopg2 yoyo-migrations From 27427d206e0d66da06a895b537e05ffdf57e2379 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Tue, 5 Jan 2021 08:50:12 +0100 Subject: [PATCH 3/6] Removes few, full, many states and adds unknown state --- schema/city_schema.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/schema/city_schema.json b/schema/city_schema.json index a346dd6..d57b319 100644 --- a/schema/city_schema.json +++ b/schema/city_schema.json @@ -87,9 +87,7 @@ "open", "nodata", "closed", - "many", - "few", - "full" + "unknown" ] }, "total": { @@ -109,7 +107,6 @@ }, "required": [ "forecast", - "free", "id", "name", "state", From f6cc3a6e10d8ce5c17131a86e8e09f73156118ba Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Tue, 5 Jan 2021 08:50:51 +0100 Subject: [PATCH 4/6] Unfreeze feedparser --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7430884..97e7b90 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ beautifulsoup4 Flask requests -feedparser==5.2.1 +feedparser pytz psycopg2 yoyo-migrations From c90534e020e0b6fd1ac82acd2e10716500599e49 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Wed, 6 Jan 2021 12:38:35 +0100 Subject: [PATCH 5/6] Allows additional properties to allow custom extensions --- schema/city_schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/city_schema.json b/schema/city_schema.json index d57b319..9d6366b 100644 --- a/schema/city_schema.json +++ b/schema/city_schema.json @@ -112,7 +112,7 @@ "state", "total" ], - "additionalProperties": false + "additionalProperties": true } } }, @@ -121,5 +121,5 @@ "last_updated", "lots" ], - "additionalProperties": false + "additionalProperties": true } \ No newline at end of file From 7c7f93641987125de4a16c7e9fff0a94f6f1460f Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Wed, 6 Jan 2021 12:52:09 +0100 Subject: [PATCH 6/6] Updates example to represent city_schema --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7b07ce..1c62e28 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,16 @@ Also please note that this is not valid JSON. Just an example for how the output }, "name": "Altmarkt", "total": 400, - "free": 235, - "state": "open|closed|nodata", + "free": 235, // >= 0, optional, can be missing, if no live data available + "state": "open|closed|nodata|unknown", "id": "lot_id", "forecast": true|false, "region": "Region X", // optional "address": "Musterstraße 5", // optional - "lot_type": "Parkhaus" // optional + "lot_type": "Parkhaus", // optional, + "opening_hours": "24/7", // optional, in OSM opening_hours syntax + "fee_hours": "Mo-Fr 07:00-22:00; PH off", // optional, in OSM opening_hours syntax + "url": "http://examplecity.com/parken/Altmarkt" // optional }, ... }