From e5af51d29b080649159f2d92e039ec56c2c2e865 Mon Sep 17 00:00:00 2001 From: James Muscat Date: Tue, 14 Apr 2015 23:42:51 +0100 Subject: [PATCH 1/6] Some schema validators object to these IDs. They don't actually do anything, so just get rid of them. --- schemas/commodity-v0.1.json | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/schemas/commodity-v0.1.json b/schemas/commodity-v0.1.json index 0e354af..c98b3dd 100644 --- a/schemas/commodity-v0.1.json +++ b/schemas/commodity-v0.1.json @@ -5,32 +5,26 @@ "additionalProperties": false, "properties": { "$schemaRef": { - "id": "#$schemaRef", "type": "string", "additionalProperties": false }, "header": { - "id": "#header", "type": "object", "additionalProperties": true, "properties": { "uploaderID": { - "id": "#uploaderID", "type": "string", "additionalProperties": false }, "softwareName": { - "id": "#softwareName", "type": "string", "additionalProperties": false }, "softwareVersion": { - "id": "#softwareVersion", "type": "string", "additionalProperties": false }, "gatewayTimestamp": { - "id": "#gatewayTimestamp", "type": "string", "format": "date-time", "description": "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property.", @@ -39,33 +33,27 @@ } }, "message": { - "id": "#message", "type": "object", "additionalProperties": true, "properties": { "systemName": { - "id": "#systemName", "type": "string", "additionalProperties": false }, "stationName": { - "id": "#stationName", "type": "string", "additionalProperties": false }, "itemName": { - "id": "#itemName", "type": "string", "additionalProperties": false }, "buyPrice": { - "id": "#buyPrice", "type": "integer", "description": "Price to buy from the market", "additionalProperties": false }, "stationStock": { - "id": "#stationStock", "type": "integer", "additionalProperties": false }, @@ -73,13 +61,11 @@ "$ref": "#/definitions/levelType" }, "sellPrice": { - "id": "#sellPrice", "type": "integer", "description": "Price to sell to the market", "additionalProperties": false }, "demand": { - "id": "#demand", "type": "integer", "additionalProperties": false }, @@ -87,7 +73,6 @@ "$ref": "#/definitions/levelType" }, "timestamp": { - "id": "#timestamp", "type": "string", "format": "date-time", "additionalProperties": false From 5bd5b001d8072b77d255df70839d9f3db5a1af67 Mon Sep 17 00:00:00 2001 From: James Muscat Date: Tue, 14 Apr 2015 23:54:46 +0100 Subject: [PATCH 2/6] Draft v2.0 schema provided by AnthorNet. --- schemas/commodity-v2.0-draft.json | 119 ++++++++++++++++++++++++++++++ src/eddn/conf/Settings.py | 3 +- 2 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 schemas/commodity-v2.0-draft.json diff --git a/schemas/commodity-v2.0-draft.json b/schemas/commodity-v2.0-draft.json new file mode 100644 index 0000000..106dd81 --- /dev/null +++ b/schemas/commodity-v2.0-draft.json @@ -0,0 +1,119 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://schemas.elite-markets.net/eddn/commodity/2#", + "type": "object", + "additionalProperties": false, + "properties": { + "$schemaRef": { + "type": "string", + "additionalProperties": false + }, + "header": { + "type": "object", + "additionalProperties": true, + "properties": { + "uploaderID": { + "type": "string", + "additionalProperties": false + }, + "softwareName": { + "type": "string", + "additionalProperties": false + }, + "softwareVersion": { + "type": "string", + "additionalProperties": false + }, + "gatewayTimestamp": { + "type": "string", + "format": "date-time", + "description": "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property.", + "additionalProperties": false + } + } + }, + "message": { + "type": "object", + "additionalProperties": false, + "properties": { + "systemName": { + "type": "string", + "additionalProperties": false + }, + "stationName": { + "type": "string", + "additionalProperties": false + }, + "timestamp": { + "type": "string", + "format": "date-time", + "additionalProperties": false + }, + "commodities": { + "type": "array", + "additionalProperties": false, + "items": { + "oneOf": [ + { + "type" : "object", + "properties": { + "name": { + "type": "string", + "additionalProperties": false + }, + "buyPrice": { + "type": "integer", + "description": "Price to buy from the market", + "additionalProperties": false + }, + "supply": { + "type": "integer", + "additionalProperties": false + }, + "supplyLevel": { + "$ref": "#/definitions/levelType" + }, + "sellPrice": { + "type": "integer", + "description": "Price to sell to the market", + "additionalProperties": false + }, + "demand": { + "type": "integer", + "additionalProperties": false + }, + "demandLevel": { + "$ref": "#/definitions/levelType" + } + }, + "required": [ + "name", + "buyPrice", + "supply", + "sellPrice", + "demand" + ] + } + ] + } + } + }, + "required": [ + "systemName", + "stationName", + "commodities", + "timestamp" + ] + } + }, + "required": [ + "$schemaRef", + "header", + "message" + ], + "definitions" : { + "levelType" : { + "enum": ["Low", "Med", "High"] + } + } +} \ No newline at end of file diff --git a/src/eddn/conf/Settings.py b/src/eddn/conf/Settings.py index 5ff62fe..10dcfce 100644 --- a/src/eddn/conf/Settings.py +++ b/src/eddn/conf/Settings.py @@ -35,7 +35,8 @@ class _Settings(object): GATEWAY_JSON_SCHEMAS = { "http://schemas.elite-markets.net/eddn/commodity/1": "schemas/commodity-v0.1.json", - "http://schemas.elite-markets.net/eddn/commodity/1/test": "schemas/commodity-v0.1.json" + "http://schemas.elite-markets.net/eddn/commodity/1/test": "schemas/commodity-v0.1.json", + "http://schemas.elite-markets.net/eddn/commodity/2": "schemas/commodity-v2.0-draft.json" } def loadFrom(self, fileName): From beb003ba2ed2f437312479a4aad15771eef90aac Mon Sep 17 00:00:00 2001 From: James Muscat Date: Wed, 15 Apr 2015 00:44:18 +0100 Subject: [PATCH 3/6] We have a dependency on argparse now. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b76fc59..73815a1 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( long_description="""\ The Elite: Dangerous Data Network allows E:D players to share data. Not affiliated with Frontier Developments. """, - install_requires=["bottle", "enum34", "gevent", "jsonschema", "pyzmq", "simplejson"], + install_requires=["argparse", "bottle", "enum34", "gevent", "jsonschema", "pyzmq", "simplejson"], entry_points={ 'console_scripts': [ 'eddn-gateway = eddn.Gateway:main', From bf7e64e97ab3eb1799b1e8da8a7eaec732b20312 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 15 Apr 2015 09:54:08 +0200 Subject: [PATCH 4/6] Refactoring and Validation - Removed useless "additionalProperties" - Ensure validation of commodities name - Refactored formating for readability --- schemas/commodity-v2.0-draft.json | 171 ++++++++++++++---------------- 1 file changed, 80 insertions(+), 91 deletions(-) diff --git a/schemas/commodity-v2.0-draft.json b/schemas/commodity-v2.0-draft.json index 106dd81..d51d342 100644 --- a/schemas/commodity-v2.0-draft.json +++ b/schemas/commodity-v2.0-draft.json @@ -1,119 +1,108 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://schemas.elite-markets.net/eddn/commodity/2#", - "type": "object", - "additionalProperties": false, - "properties": { - "$schemaRef": { - "type": "string", - "additionalProperties": false + "$schema" : "http://json-schema.org/draft-04/schema#", + "id" : "http://schemas.elite-markets.net/eddn/commodity/2#", + "type" : "object", + "additionalProperties" : false, + "required" : [ "$schemaRef", "header", "message" ], + "properties" : { + "$schemaRef" : { + "type" : "string" }, - "header": { - "type": "object", - "additionalProperties": true, - "properties": { - "uploaderID": { - "type": "string", - "additionalProperties": false - }, - "softwareName": { - "type": "string", - "additionalProperties": false - }, - "softwareVersion": { - "type": "string", - "additionalProperties": false - }, + + "header" : { + "type" : "object", + "additionalProperties" : true, + "properties" : { + "uploaderID" : { "type": "string" }, + "softwareName" : { "type": "string" }, + "softwareVersion" : { "type": "string" }, "gatewayTimestamp": { "type": "string", "format": "date-time", - "description": "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property.", - "additionalProperties": false + "description": "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property." } } }, + "message": { "type": "object", "additionalProperties": false, + "required": [ "systemName", "stationName", "timestamp", "commodities" ], "properties": { "systemName": { - "type": "string", - "additionalProperties": false + "type": "string" }, "stationName": { - "type": "string", - "additionalProperties": false + "type": "string" }, "timestamp": { "type": "string", - "format": "date-time", - "additionalProperties": false + "format": "date-time" }, "commodities": { "type": "array", - "additionalProperties": false, "items": { "oneOf": [ - { - "type" : "object", - "properties": { - "name": { - "type": "string", - "additionalProperties": false - }, - "buyPrice": { - "type": "integer", - "description": "Price to buy from the market", - "additionalProperties": false - }, - "supply": { - "type": "integer", - "additionalProperties": false - }, - "supplyLevel": { - "$ref": "#/definitions/levelType" - }, - "sellPrice": { - "type": "integer", - "description": "Price to sell to the market", - "additionalProperties": false - }, - "demand": { - "type": "integer", - "additionalProperties": false - }, - "demandLevel": { - "$ref": "#/definitions/levelType" - } - }, - "required": [ - "name", - "buyPrice", - "supply", - "sellPrice", - "demand" - ] - } - ] + { + "type" : "object", + "additionalProperties" : false, + "required" : [ "name", "buyPrice", "supply", "sellPrice", "demand" ], + "properties" : { + "name": { + "$ref": "#/definitions/commoditiesName" + }, + "buyPrice": { + "type": "integer", + "description": "Price to buy from the market" + }, + "supply": { + "type": "integer" + }, + "supplyLevel": { + "$ref": "#/definitions/levelType" + }, + "sellPrice": { + "type": "integer", + "description": "Price to sell to the market" + }, + "demand": { + "type": "integer" + }, + "demandLevel": { + "$ref": "#/definitions/levelType" + } + } + } + ] } } - }, - "required": [ - "systemName", - "stationName", - "commodities", - "timestamp" - ] + } } }, - "required": [ - "$schemaRef", - "header", - "message" - ], - "definitions" : { - "levelType" : { - "enum": ["Low", "Med", "High"] - } - } + + "definitions" : { + "levelType" : { + "enum": ["Low", "Med", "High"] + }, + "commoditiesName" : { + "enum": [ + "explosives", "hydrogen fuel", "mineral oil", "pesticides", + "clothing", "consumer technology", "domestic appliances", + "beer", "liquor", "narcotics", "tobacco", "wine", + "algae", "animal meat", "coffee", "fish", "food cartridges", "fruit and vegetables", "grain", "synthetic meat", "tea", + "polymers", "semiconductors", "superconductors", + "atmospheric processors", "crop harvesters", "marine equipment", "microbial furnaces", "mineral extractors", "power generators", "water purifiers", + "agri-medicines", "basic medicines", "combat stabilisers", "performance enhancers", "progenitor cells", + "aluminium", "beryllium", "cobalt", "copper", "gallium", "gold", "indium", "lithium", "palladium", "platinum", "silver", "tantalum", "titanium", "uranium", + "bauxite", "bertrandite", "coltan", "gallite", "indite", "lepidolite", "painite", "rutile", "uraninite", + "imperial slaves", "slaves", + "advanced catalysers", "animal monitors", "aquaponic systems", "auto-fabricators", "bioreducing lichen", "computer components", "h.e. suits", + "land enrichment systems", "resonating separators", "robotics", "terrain enrichment systems", + "leather", "natural fabrics", "synthetic fabrics", + "biowaste", "chemical waste", "scrap", "toxic waste", + "battle weapons", "non-lethal weapons", "personal weapons", "reactive armour" + ], + "description": "Valid commodities names. Have to be lowercase." + } + } } \ No newline at end of file From fd496a0e29d22951980f97cb2ed82f50a1b62910 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 15 Apr 2015 10:08:11 +0200 Subject: [PATCH 5/6] Update commoditiesName description - Update commoditiesName description. - Some refactoring --- schemas/commodity-v2.0-draft.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/schemas/commodity-v2.0-draft.json b/schemas/commodity-v2.0-draft.json index d51d342..d835d31 100644 --- a/schemas/commodity-v2.0-draft.json +++ b/schemas/commodity-v2.0-draft.json @@ -5,9 +5,7 @@ "additionalProperties" : false, "required" : [ "$schemaRef", "header", "message" ], "properties" : { - "$schemaRef" : { - "type" : "string" - }, + "$schemaRef" : { "type": "string" }, "header" : { "type" : "object", @@ -16,7 +14,7 @@ "uploaderID" : { "type": "string" }, "softwareName" : { "type": "string" }, "softwareVersion" : { "type": "string" }, - "gatewayTimestamp": { + "gatewayTimestamp" : { "type": "string", "format": "date-time", "description": "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property." @@ -102,7 +100,7 @@ "biowaste", "chemical waste", "scrap", "toxic waste", "battle weapons", "non-lethal weapons", "personal weapons", "reactive armour" ], - "description": "Valid commodities names. Have to be lowercase." + "description": "Valid commodities names. Have to be lowercase (JSON schema doesn't propose insensitive validation)." } } } \ No newline at end of file From fa9f06b9c4636dc11e58c671f8ed13975e4210bb Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 15 Apr 2015 12:18:58 +0200 Subject: [PATCH 6/6] Revert Commodity name validation --- schemas/commodity-v2.0-draft.json | 36 ++++++++----------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/schemas/commodity-v2.0-draft.json b/schemas/commodity-v2.0-draft.json index d835d31..d6ee7c2 100644 --- a/schemas/commodity-v2.0-draft.json +++ b/schemas/commodity-v2.0-draft.json @@ -28,18 +28,19 @@ "required": [ "systemName", "stationName", "timestamp", "commodities" ], "properties": { "systemName": { - "type": "string" + "type" : "string" }, "stationName": { - "type": "string" + "type" : "string" }, "timestamp": { - "type": "string", - "format": "date-time" + "type" : "string", + "format" : "date-time" }, "commodities": { - "type": "array", - "items": { + "type" : "array", + "minItems" : 1, + "items" : { "oneOf": [ { "type" : "object", @@ -47,7 +48,8 @@ "required" : [ "name", "buyPrice", "supply", "sellPrice", "demand" ], "properties" : { "name": { - "$ref": "#/definitions/commoditiesName" + "type" : "string", + "minLength" : 1 }, "buyPrice": { "type": "integer", @@ -81,26 +83,6 @@ "definitions" : { "levelType" : { "enum": ["Low", "Med", "High"] - }, - "commoditiesName" : { - "enum": [ - "explosives", "hydrogen fuel", "mineral oil", "pesticides", - "clothing", "consumer technology", "domestic appliances", - "beer", "liquor", "narcotics", "tobacco", "wine", - "algae", "animal meat", "coffee", "fish", "food cartridges", "fruit and vegetables", "grain", "synthetic meat", "tea", - "polymers", "semiconductors", "superconductors", - "atmospheric processors", "crop harvesters", "marine equipment", "microbial furnaces", "mineral extractors", "power generators", "water purifiers", - "agri-medicines", "basic medicines", "combat stabilisers", "performance enhancers", "progenitor cells", - "aluminium", "beryllium", "cobalt", "copper", "gallium", "gold", "indium", "lithium", "palladium", "platinum", "silver", "tantalum", "titanium", "uranium", - "bauxite", "bertrandite", "coltan", "gallite", "indite", "lepidolite", "painite", "rutile", "uraninite", - "imperial slaves", "slaves", - "advanced catalysers", "animal monitors", "aquaponic systems", "auto-fabricators", "bioreducing lichen", "computer components", "h.e. suits", - "land enrichment systems", "resonating separators", "robotics", "terrain enrichment systems", - "leather", "natural fabrics", "synthetic fabrics", - "biowaste", "chemical waste", "scrap", "toxic waste", - "battle weapons", "non-lethal weapons", "personal weapons", "reactive armour" - ], - "description": "Valid commodities names. Have to be lowercase (JSON schema doesn't propose insensitive validation)." } } } \ No newline at end of file