mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 16:58:28 +00:00
Clarify JSON schema validation errors
This commit is contained in:
parent
8b61aa9ae7
commit
3471b03ef9
@ -62,8 +62,6 @@ class Response(aiohttp.web.Response):
|
|||||||
try:
|
try:
|
||||||
jsonschema.validate(answer, self._output_schema)
|
jsonschema.validate(answer, self._output_schema)
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
log.error("Invalid output schema {} '{}' in schema: {}".format(e.validator,
|
log.error("Invalid output query. JSON schema error: {}".format(e.message))
|
||||||
e.validator_value,
|
|
||||||
json.dumps(e.schema)))
|
|
||||||
raise aiohttp.web.HTTPBadRequest(text="{}".format(e))
|
raise aiohttp.web.HTTPBadRequest(text="{}".format(e))
|
||||||
self.body = json.dumps(answer, indent=4, sort_keys=True).encode('utf-8')
|
self.body = json.dumps(answer, indent=4, sort_keys=True).encode('utf-8')
|
||||||
|
@ -28,7 +28,6 @@ log = logging.getLogger(__name__)
|
|||||||
from ..modules.vm_error import VMError
|
from ..modules.vm_error import VMError
|
||||||
from .response import Response
|
from .response import Response
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def parse_request(request, input_schema):
|
def parse_request(request, input_schema):
|
||||||
"""Parse body of request and raise HTTP errors in case of problems"""
|
"""Parse body of request and raise HTTP errors in case of problems"""
|
||||||
@ -42,9 +41,7 @@ def parse_request(request, input_schema):
|
|||||||
try:
|
try:
|
||||||
jsonschema.validate(request.json, input_schema)
|
jsonschema.validate(request.json, input_schema)
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
log.error("Invalid input schema {} '{}' in schema: {}".format(e.validator,
|
log.error("Invalid input query. JSON schema error: {}".format(e.message))
|
||||||
e.validator_value,
|
|
||||||
json.dumps(e.schema)))
|
|
||||||
raise aiohttp.web.HTTPBadRequest(text="Request is not {} '{}' in schema: {}".format(
|
raise aiohttp.web.HTTPBadRequest(text="Request is not {} '{}' in schema: {}".format(
|
||||||
e.validator,
|
e.validator,
|
||||||
e.validator_value,
|
e.validator_value,
|
||||||
|
Loading…
Reference in New Issue
Block a user