mirror of
https://github.com/EDCD/EDDN.git
synced 2026-10-22 20:42:10 +03:00
Configure Validator with our schema (don't do the validation yet).
This commit is contained in:
1 parent
7786d41d67
commit
a7925923cf
4 files changed
+117
No files matched your search
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"id": "http://schemas.elite-markets.net/eddn/commodity/1#",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"header": {
|
||||
"id": "#header",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"uploaderID": {
|
||||
"id": "#uploaderID",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"softwareName": {
|
||||
"id": "#softwareName",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"softwareVersion": {
|
||||
"id": "#softwareVersion",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uploaderID",
|
||||
"softwareName",
|
||||
"softwareVersion"
|
||||
]
|
||||
},
|
||||
"message": {
|
||||
"id": "#message",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"categoryName": {
|
||||
"id": "#categoryName",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"buyPrice": {
|
||||
"id": "#buyPrice",
|
||||
"type": "integer",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"timestamp": {
|
||||
"id": "#timestamp",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"stationStock": {
|
||||
"id": "#stationStock",
|
||||
"type": "integer",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"stationName": {
|
||||
"id": "#stationName",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"systemName": {
|
||||
"id": "#systemName",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"demand": {
|
||||
"id": "#demand",
|
||||
"type": "integer",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sellPrice": {
|
||||
"id": "#sellPrice",
|
||||
"type": "integer",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"itemName": {
|
||||
"id": "#itemName",
|
||||
"type": "string",
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"categoryName",
|
||||
"buyPrice",
|
||||
"timestamp",
|
||||
"stationStock",
|
||||
"stationName",
|
||||
"systemName",
|
||||
"demand",
|
||||
"sellPrice",
|
||||
"itemName"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"$schemaRef",
|
||||
"header",
|
||||
"message"
|
||||
]
|
||||
}
|
||||
@@ -30,6 +30,9 @@ for binding in Settings.GATEWAY_SENDER_BINDINGS:
|
||||
|
||||
validator = Validator()
|
||||
|
||||
for schemaRef, schemaFile in Settings.GATEWAY_JSON_SCHEMAS.iteritems():
|
||||
validator.addSchemaResource(schemaRef, schemaFile)
|
||||
|
||||
|
||||
def push_message(string_message):
|
||||
"""
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import simplejson
|
||||
from enum import IntEnum
|
||||
|
||||
|
||||
@@ -5,6 +6,12 @@ class Validator(object):
|
||||
|
||||
schemas = {"http://example.com": {}}
|
||||
|
||||
def addSchemaResource(self, schemaRef, schemaFile):
|
||||
if schemaRef in self.schemas.keys():
|
||||
raise Exception("Attempted to redefine schema for " + schemaRef)
|
||||
schema = simplejson.load(open(schemaFile, "r"))
|
||||
self.schemas[schemaRef] = schema
|
||||
|
||||
def validate(self, json_object):
|
||||
results = ValidationResults()
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ GATEWAY_SENDER_BINDINGS = ["tcp://*:8500"]
|
||||
|
||||
GATEWAY_IP_KEY_SALT = None
|
||||
|
||||
GATEWAY_JSON_SCHEMAS = {
|
||||
"http://schemas.elite-markets.net/eddn/commodity/1": "../schemas/commodity-v0.1.json"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Logging Settings
|
||||
###############################################################################
|
||||
|
||||
Reference in new issue
Block a user